LiteFX 0.5.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 class VirtualAllocator;
68
69#pragma region "Enumerations"
70
71 // NOLINTBEGIN(performance-enum-size)
72
80 None = 0x00000000,
81
85 GPU = 0x00000001,
86
90 CPU = 0x00000002,
91
95 Other = 0x7FFFFFFF,
96 };
97
114 enum class QueueType : UInt32 {
118 None = 0x00000000,
119
123 Graphics = 0x00000001,
124
128 Compute = 0x00000002,
129
133 Transfer = 0x00000004,
134
141 VideoDecode = 0x00000010,
142
149 VideoEncode = 0x00000020,
150
154 Other = 0x7FFFFFFF
155 };
156
160 enum class QueuePriority {
164 Normal = 33,
165
169 High = 66,
170
177 Realtime = 100
178 };
179
183 enum class Format {
184 None = 0x00000000,
193 R8_UNORM,
194 R8_SNORM,
197 R8_UINT,
198 R8_SINT,
199 R8_SRGB,
204 R8G8_UINT,
205 R8G8_SINT,
206 R8G8_SRGB,
254 R16_UNORM,
255 R16_SNORM,
258 R16_UINT,
259 R16_SINT,
282 R32_UINT,
283 R32_SINT,
294 R64_UINT,
295 R64_SINT,
308 D16_UNORM,
311 S8_UINT,
319 BC2_UNORM,
320 BC2_SRGB,
321 BC3_UNORM,
322 BC3_SRGB,
323 BC4_UNORM,
324 BC4_SNORM,
325 BC5_UNORM,
326 BC5_SNORM,
329 BC7_UNORM,
330 BC7_SRGB,
331 Other = 0x7FFFFFFF
332 };
333
340 enum class BufferFormat : UInt32 {
341 None = 0x00000000,
342 X16F = 0x10000101,
343 X16I = 0x10000201,
344 X16U = 0x10000401,
345 XY16F = 0x10000102,
346 XY16I = 0x10000202,
347 XY16U = 0x10000402,
348 XYZ16F = 0x10000103,
349 XYZ16I = 0x10000203,
350 XYZ16U = 0x10000403,
351 XYZW16F = 0x10000104,
352 XYZW16I = 0x10000204,
353 XYZW16U = 0x10000404,
354 X32F = 0x20000101,
355 X32I = 0x20000201,
356 X32U = 0x20000401,
357 XY32F = 0x20000102,
358 XY32I = 0x20000202,
359 XY32U = 0x20000402,
360 XYZ32F = 0x20000103,
361 XYZ32I = 0x20000203,
362 XYZ32U = 0x20000403,
363 XYZW32F = 0x20000104,
364 XYZW32I = 0x20000204,
365 XYZW32U = 0x20000404
366 };
367
376 Binormal = 0x00000001,
377
381 BlendIndices = 0x00000002,
382
386 BlendWeight = 0x00000003,
387
391 Color = 0x00000004,
392
396 Normal = 0x00000005,
397
401 Position = 0x00000006,
402
406 TransformedPosition = 0x00000007,
407
411 PointSize = 0x00000008,
412
416 Tangent = 0x00000009,
417
421 TextureCoordinate = 0x0000000A,
422
426 Arbitrary = 0x0000000B,
427
431 Unknown = 0x7FFFFFFF
432 };
433
442 enum class DescriptorType {
449 ConstantBuffer = 0x00000001,
450
461 StructuredBuffer = 0x00000002,
462
472 RWStructuredBuffer = 0x00000012,
473
484 Texture = 0x00000003,
485
492 RWTexture = 0x00000013,
493
497 Sampler = 0x00000004,
498
502 InputAttachment = 0x00000005,
503
510 Buffer = 0x00000006,
511
518 RWBuffer = 0x00000016,
519
526 ByteAddressBuffer = 0x00000007,
527
534 RWByteAddressBuffer = 0x00000017,
535
539 AccelerationStructure = 0x00000008,
540
563 ResourceDescriptorHeap = 0x00000009,
564
574 SamplerDescriptorHeap = 0x0000000A
575 };
576
584 None = 0x00,
585
589 Resource = 0x01,
590
594 Sampler = 0x02
595 };
596
601 enum class BufferType {
605 Vertex = 0x00000001,
606
610 Index = 0x00000002,
611
618 Uniform = 0x00000003,
619
626 Storage = 0x00000004,
634 Texel = 0x00000005,
642 AccelerationStructure = 0x00000006,
643
647 ShaderBindingTable = 0x00000007,
648
666 Indirect = 0x00000008,
667
674 Other = 0x7FFFFFFF
675 };
676
710 enum class ResourceHeap {
719 Staging = 0x00000001,
720
728 Resource = 0x00000002,
729
737 Dynamic = 0x00000010,
738
742 Readback = 0x00000100,
743
752 GPUUpload = 0x00001000
753 };
754
761 enum class ResourceUsage {
765 None = 0x0000,
766
774 AllowWrite = 0x0001,
775
782 TransferSource = 0x0010,
783
790 TransferDestination = 0x0020,
791
795 RenderTarget = 0x0040,
796
805
810
816
824 Volatile = 0x1000
825 };
826
834 Default = 0x00,
835
840 StayWithinBudget = 0x01,
841
846 DontExpandCache = 0x02
847 };
848
856 Default = 0x01,
857
863 Linear = 0x02
864 };
865
873 OptimizePacking = 0x01,
874
878 OptimizeTime = 0x02,
879 };
880
890 Fast = 0x01,
891
895 Balanced = 0x02,
896
900 Full = 0x03
901 };
902
906 enum class IndexType : UInt32 {
910 UInt16 = 0x00000010,
911
915 UInt32 = 0x00000020
916 };
917
926 Vertex = 0,
927
931 Instance = 1
932 };
933
937 enum class PrimitiveTopology {
941 PointList = 0x00010001,
942
947 LineList = 0x00020001,
948
953 TriangleList = 0x00040001,
954
959 LineStrip = 0x00020002,
960
965 TriangleStrip = 0x00040002
966 };
967
971 enum class ShaderStage : UInt32 {
975 Vertex = 0x00000001,
976
980 TessellationControl = 0x00000002,
981
985 TessellationEvaluation = 0x00000004,
986
993 Geometry = 0x00000008,
994
998 Fragment = 0x00000010,
999
1003 Compute = 0x00000020,
1004
1008 Task = 0x00000040,
1009
1013 Mesh = 0x00000080,
1014
1018 RayGeneration = 0x00000100,
1019
1023 AnyHit = 0x00000200,
1024
1028 ClosestHit = 0x00000400,
1029
1033 Miss = 0x00000800,
1034
1038 Intersection = 0x00001000,
1039
1043 Callable = 0x00002000,
1044
1049
1054
1059
1064
1068 Other = 0x7FFFFFFF
1069 };
1070
1075 enum class ShaderRecordType {
1079 RayGeneration = 0x01,
1080
1084 HitGroup = 0x02,
1089 Intersection = 0x03,
1090
1094 Miss = 0x04,
1095
1099 Callable = 0x05,
1100
1104 Invalid = 0x7FFFFFFF
1105 };
1106
1116
1120 HitGroup = 0x02,
1121
1125 Miss = 0x04,
1126
1130 Callable = 0x08,
1131
1136 };
1137
1142 enum class PolygonMode {
1146 Solid = 0x00000001,
1147
1151 Wireframe = 0x00000002,
1152
1156 Point = 0x00000004
1157 };
1158
1163 enum class CullMode {
1167 FrontFaces = 0x00000001,
1168
1172 BackFaces = 0x00000002,
1173
1177 Both = 0x00000004,
1178
1182 Disabled = 0x0000000F
1183 };
1184
1190 enum class CullOrder {
1194 ClockWise = 0x00000001,
1195
1199 CounterClockWise = 0x00000002
1200 };
1201
1205 enum class RenderTargetType {
1209 Color = 0x00000001,
1210
1214 DepthStencil = 0x00000002,
1215
1222 Present = 0x00000004
1223 };
1224
1232 None = 0x00,
1233
1237 Clear = 0x01,
1238
1242 ClearStencil = 0x02,
1243
1251 Volatile = 0x04
1252 };
1253
1258 enum class ImageDimensions {
1262 DIM_1 = 0x01,
1263
1267 DIM_2 = 0x02,
1268
1272 DIM_3 = 0x03,
1273
1277 CUBE = 0x04
1278 };
1287 x1 = 0x00000001,
1288
1292 x2 = 0x00000002,
1293
1297 x4 = 0x00000004,
1298
1302 x8 = 0x00000008,
1303
1307 x16 = 0x00000010,
1308
1312 x32 = 0x00000020,
1313
1317 x64 = 0x00000040
1318 };
1319
1324 enum class FilterMode {
1328 Nearest = 0x00000001,
1329
1333 Linear = 0x00000002
1334 };
1335
1341 enum class MipMapMode {
1345 Nearest = 0x00000001,
1346
1350 Linear = 0x00000002
1351 };
1352
1356 enum class BorderMode {
1360 Repeat = 0x00000001,
1361
1365 RepeatMirrored = 0x00010001,
1366
1370 ClampToEdge = 0x00000002,
1371
1375 ClampToEdgeMirrored = 0x00010002,
1376
1380 ClampToBorder = 0x00000003,
1381 };
1382
1387 enum class CompareOperation {
1391 Never = 0x00000000,
1392
1396 Less = 0x00000001,
1397
1401 Greater = 0x0000002,
1402
1406 Equal = 0x00000003,
1407
1411 LessEqual = 0x00000004,
1412
1416 GreaterEqual = 0x00000005,
1417
1421 NotEqual = 0x00000006,
1422
1426 Always = 0x00000007
1427 };
1428
1433 enum class StencilOperation {
1437 Keep = 0x00000000,
1438
1442 Zero = 0x00000001,
1443
1447 Replace = 0x00000002,
1448
1452 IncrementClamp = 0x00000003,
1453
1457 DecrementClamp = 0x00000004,
1458
1462 Invert = 0x00000005,
1463
1467 IncrementWrap = 0x00000006,
1468
1472 DecrementWrap = 0x00000007
1473 };
1474
1479 enum class BlendFactor {
1480 Zero = 0,
1481 One = 1,
1482 SourceColor = 2,
1484 DestinationColor = 4,
1486 SourceAlpha = 6,
1488 DestinationAlpha = 8,
1490 ConstantColor = 10,
1492 ConstantAlpha = 12,
1495 Source1Color = 15,
1497 Source1Alpha = 17,
1499 };
1500
1505 enum class WriteMask {
1509 R = 0x01,
1510
1514 G = 0x02,
1515
1519 B = 0x04,
1520
1524 A = 0x08
1525 };
1526
1531 enum class BlendOperation {
1532 Add = 0x01,
1533 Subtract = 0x02,
1534 ReverseSubtract = 0x03,
1535 Minimum = 0x04,
1536 Maximum = 0x05
1537 };
1538
1545 enum class PipelineStage {
1554 None = 0x00000000,
1555
1564 All = 0x00000001,
1565
1574 Draw = 0x00000002,
1575
1582 InputAssembly = 0x00000004,
1583
1590 Vertex = 0x00000006,
1591
1598 TessellationControl = 0x00000008,
1599
1606 TessellationEvaluation = 0x00000010,
1607
1614 Geometry = 0x00000020,
1615
1622 Fragment = 0x00000040,
1623
1630 DepthStencil = 0x00000080,
1631
1638 Indirect = 0x00000100,
1639
1646 RenderTarget = 0x00000200,
1647
1656 Compute = 0x00000400,
1657
1664 Transfer = 0x00000800,
1665
1672 Resolve = 0x00001000,
1673
1681 AccelerationStructureBuild = 0x00010000,
1682
1690 AccelerationStructureCopy = 0x00020000,
1691
1698 Raytracing = 0x00040000,
1699 };
1700
1709 enum class ResourceAccess {
1718 None = 0x7FFFFFFF,
1719
1726 VertexBuffer = 0x00000001,
1727
1734 IndexBuffer = 0x00000002,
1735
1742 UniformBuffer = 0x00000004,
1743
1750 RenderTarget = 0x00000008,
1751
1758 DepthStencilRead = 0x00000010,
1759
1766 DepthStencilWrite = 0x00000020,
1767
1774 ShaderRead = 0x00000040,
1775
1782 ShaderReadWrite = 0x00000080,
1783
1790 Indirect = 0x00000100,
1791
1798 TransferRead = 0x00000200,
1799
1806 TransferWrite = 0x00000400,
1807
1814 ResolveRead = 0x00000800,
1815
1822 ResolveWrite = 0x00001000,
1823
1832 Common = 0x00002000,
1833
1840 AccelerationStructureRead = 0x00010000,
1841
1848 AccelerationStructureWrite = 0x00020000,
1849 };
1850
1858 enum class ImageLayout {
1865 Common = 0x00000001,
1866
1873 ShaderResource = 0x00000002,
1874
1881 ReadWrite = 0x00000003,
1882
1889 CopySource = 0x00000010,
1890
1897 CopyDestination = 0x00000011,
1898
1905 RenderTarget = 0x00000020,
1906
1913 DepthRead = 0x00000021,
1914
1921 DepthWrite = 0x00000022,
1922
1931 Present = 0x00000023,
1932
1939 ResolveSource = 0x00000024,
1940
1947 ResolveDestination = 0x00000025,
1948
1959 Undefined = 0x7FFFFFFF
1960 };
1961
1966 enum class GeometryFlags {
1970 None = 0x00,
1971
1975 Opaque = 0x01,
1976
1980 OneShotAnyHit = 0x02
1981 };
1982
1992 None = 0x0000,
1993
1997 AllowUpdate = 0x0001,
1998
2002 AllowCompaction = 0x0002,
2003
2010 PreferFastTrace = 0x0004,
2011
2018 PreferFastBuild = 0x0008,
2019
2023 MinimizeMemory = 0x0010
2024 };
2025
2029 enum class InstanceFlags {
2033 None = 0x00,
2034
2038 DisableCull = 0x01,
2039
2043 FlipWinding = 0x02,
2044
2052 ForceOpaque = 0x04,
2053
2061 ForceNonOpaque = 0x08
2062 };
2063
2064 // NOLINTEND(performance-enum-size)
2065
2066#pragma endregion
2067
2068#pragma region "Flags"
2069
2070 LITEFX_DEFINE_FLAGS(QueueType);
2071 LITEFX_DEFINE_FLAGS(ShaderStage);
2072 LITEFX_DEFINE_FLAGS(PipelineStage);
2073 LITEFX_DEFINE_FLAGS(ResourceAccess);
2074 LITEFX_DEFINE_FLAGS(BufferFormat);
2075 LITEFX_DEFINE_FLAGS(WriteMask);
2076 LITEFX_DEFINE_FLAGS(RenderTargetFlags);
2077 LITEFX_DEFINE_FLAGS(GeometryFlags);
2078 LITEFX_DEFINE_FLAGS(ResourceUsage);
2079 LITEFX_DEFINE_FLAGS(AccelerationStructureFlags);
2080 LITEFX_DEFINE_FLAGS(InstanceFlags);
2081 LITEFX_DEFINE_FLAGS(ShaderBindingGroup);
2082
2083#pragma endregion
2084
2085#pragma region "Helper Functions"
2086
2092 return static_cast<UInt32>(format) & 0x000000FF; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2093 }
2094
2100 return (static_cast<UInt32>(format) & 0xFF000000) >> 24; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2101 }
2102
2108 return (static_cast<UInt32>(format) & 0x0000FF00) >> 8; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2109 }
2110
2114 constexpr size_t getSize(Format format) {
2115 switch (format) {
2116 using enum Format;
2117 case None:
2118 return 0; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2119 case R4G4_UNORM:
2120 case R8_UNORM:
2121 case R8_SNORM:
2122 case R8_USCALED:
2123 case R8_SSCALED:
2124 case R8_UINT:
2125 case R8_SINT:
2126 case R8_SRGB:
2127 case S8_UINT:
2128 return 1; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2129 case R4G4B4A4_UNORM:
2130 case B4G4R4A4_UNORM:
2131 case R5G6B5_UNORM:
2132 case B5G6R5_UNORM:
2133 case R5G5B5A1_UNORM:
2134 case B5G5R5A1_UNORM:
2135 case A1R5G5B5_UNORM:
2136 case R8G8_UNORM:
2137 case R8G8_SNORM:
2138 case R8G8_USCALED:
2139 case R8G8_SSCALED:
2140 case R8G8_UINT:
2141 case R8G8_SINT:
2142 case R8G8_SRGB:
2143 case R16_UNORM:
2144 case R16_SNORM:
2145 case R16_USCALED:
2146 case R16_SSCALED:
2147 case R16_UINT:
2148 case R16_SINT:
2149 case R16_SFLOAT:
2150 case D16_UNORM:
2151 return 2; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2152 case R8G8B8_UNORM:
2153 case R8G8B8_SNORM:
2154 case R8G8B8_USCALED:
2155 case R8G8B8_SSCALED:
2156 case R8G8B8_UINT:
2157 case R8G8B8_SINT:
2158 case R8G8B8_SRGB:
2159 case B8G8R8_UNORM:
2160 case B8G8R8_SNORM:
2161 case B8G8R8_USCALED:
2162 case B8G8R8_SSCALED:
2163 case B8G8R8_UINT:
2164 case B8G8R8_SINT:
2165 case B8G8R8_SRGB:
2166 case D16_UNORM_S8_UINT:
2167 return 3; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2168 case R8G8B8A8_UNORM:
2169 case R8G8B8A8_SNORM:
2170 case R8G8B8A8_USCALED:
2171 case R8G8B8A8_SSCALED:
2172 case R8G8B8A8_UINT:
2173 case R8G8B8A8_SINT:
2174 case R8G8B8A8_SRGB:
2175 case B8G8R8A8_UNORM:
2176 case B8G8R8A8_SNORM:
2177 case B8G8R8A8_USCALED:
2178 case B8G8R8A8_SSCALED:
2179 case B8G8R8A8_UINT:
2180 case B8G8R8A8_SINT:
2181 case B8G8R8A8_SRGB:
2182 case A8B8G8R8_UNORM:
2183 case A8B8G8R8_SNORM:
2184 case A8B8G8R8_USCALED:
2185 case A8B8G8R8_SSCALED:
2186 case A8B8G8R8_UINT:
2187 case A8B8G8R8_SINT:
2188 case A8B8G8R8_SRGB:
2189 case A2R10G10B10_UNORM:
2190 case A2R10G10B10_SNORM:
2193 case A2R10G10B10_UINT:
2194 case A2R10G10B10_SINT:
2195 case A2B10G10R10_UNORM:
2196 case A2B10G10R10_SNORM:
2199 case A2B10G10R10_UINT:
2200 case A2B10G10R10_SINT:
2201 case R16G16_UNORM:
2202 case R16G16_SNORM:
2203 case R16G16_USCALED:
2204 case R16G16_SSCALED:
2205 case R16G16_UINT:
2206 case R16G16_SINT:
2207 case R16G16_SFLOAT:
2208 case R32_UINT:
2209 case R32_SINT:
2210 case R32_SFLOAT:
2211 case B10G11R11_UFLOAT:
2212 case E5B9G9R9_UFLOAT:
2213 case X8_D24_UNORM:
2214 case D32_SFLOAT:
2215 case D24_UNORM_S8_UINT:
2216 return 4; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2217 case R16G16B16_UNORM:
2218 case R16G16B16_SNORM:
2219 case R16G16B16_USCALED:
2220 case R16G16B16_SSCALED:
2221 case R16G16B16_UINT:
2222 case R16G16B16_SINT:
2223 case R16G16B16_SFLOAT:
2224 return 6; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2225 case R16G16B16A16_UNORM:
2226 case R16G16B16A16_SNORM:
2229 case R16G16B16A16_UINT:
2230 case R16G16B16A16_SINT:
2232 case R32G32_UINT:
2233 case R32G32_SINT:
2234 case R32G32_SFLOAT:
2235 case R64_UINT:
2236 case R64_SINT:
2237 case R64_SFLOAT:
2238 case D32_SFLOAT_S8_UINT: // NOTE: This may be wrong here - spec states, however, that 24 bits are unused.
2239 case BC1_RGB_UNORM:
2240 case BC1_RGB_SRGB:
2241 case BC1_RGBA_UNORM:
2242 case BC1_RGBA_SRGB:
2243 case BC4_UNORM:
2244 case BC4_SNORM:
2245 return 8; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2246 case R32G32B32_UINT:
2247 case R32G32B32_SINT:
2248 case R32G32B32_SFLOAT:
2249 return 12; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2250 case R32G32B32A32_UINT:
2251 case R32G32B32A32_SINT:
2253 case R64G64_UINT:
2254 case R64G64_SINT:
2255 case R64G64_SFLOAT:
2256 case BC2_UNORM:
2257 case BC2_SRGB:
2258 case BC3_UNORM:
2259 case BC3_SRGB:
2260 case BC5_UNORM:
2261 case BC5_SNORM:
2262 case BC6H_UFLOAT:
2263 case BC6H_SFLOAT:
2264 case BC7_UNORM:
2265 case BC7_SRGB:
2266 return 16; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2267 case R64G64B64_UINT:
2268 case R64G64B64_SINT:
2269 case R64G64B64_SFLOAT:
2270 return 24; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2271 case R64G64B64A64_UINT:
2272 case R64G64B64A64_SINT:
2274 return 32; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2275 default:
2276 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.
2277 }
2278 }
2279
2284 constexpr bool hasDepth(Format format) noexcept {
2285 constexpr std::array<Format, 6> depthFormats {
2292 };
2293
2294 return std::any_of(std::begin(depthFormats), std::end(depthFormats), [&](Format f) { return f == format; });
2295 }
2296
2301 constexpr bool hasStencil(Format format) noexcept {
2302 constexpr std::array<Format, 4> stencilFormats {
2307 };
2308
2309 return std::any_of(std::begin(stencilFormats), std::end(stencilFormats), [&](Format f) { return f == format; });
2310 }
2311
2312#pragma endregion
2313
2314#pragma region "Data Types"
2315
2321 struct LITEFX_RENDERING_API alignas(16) IndirectBatch { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2326 UInt32 VertexCount{ };
2327
2332 UInt32 InstanceCount{ };
2333
2338 UInt32 FirstVertex{ };
2339
2344 UInt32 FirstInstance{ };
2345 };
2346
2347#pragma warning(push)
2348#pragma warning(disable: 4324) // Structure was padded due to alignment specifier
2354 struct LITEFX_RENDERING_API alignas(16) IndirectIndexedBatch { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2359 UInt32 IndexCount{ };
2360
2365 UInt32 InstanceCount{ };
2366
2371 UInt32 FirstIndex{ };
2372
2376 Int32 VertexOffset{ };
2377
2382 UInt32 FirstInstance{ };
2383 };
2384
2390 struct LITEFX_RENDERING_API alignas(16) IndirectDispatchBatch { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
2394 UInt32 X{ 1 };
2395
2399 UInt32 Y{ 1 };
2400
2404 UInt32 Z{ 1 };
2405 };
2406#pragma warning(pop)
2407
2413 struct LITEFX_RENDERING_API ResourceAllocationInfo final {
2414 public:
2419 {
2423 BufferType Type{ BufferType::Uniform };
2424
2428 size_t ElementSize{ 0u };
2429
2433 UInt32 Elements{ 1u };
2434
2438 ResourceHeap Heap{ ResourceHeap::Dynamic };
2439
2447 SharedPtr<const IVertexBufferLayout> VertexBufferLayout{ nullptr };
2448
2456 SharedPtr<const IIndexBufferLayout> IndexBufferLayout{ nullptr };
2457 };
2458
2463 {
2467 Format Format{ Format::R8G8B8A8_SRGB };
2468
2472 ImageDimensions Dimensions{ ImageDimensions::DIM_2 };
2473
2477 Size3d Size{ };
2478
2482 UInt32 Levels{ 1u };
2483
2487 UInt32 Layers{ 1u };
2488
2492 MultiSamplingLevel Samples{ MultiSamplingLevel::x1 };
2493 };
2494
2495 public:
2500
2504 ResourceUsage Usage{ ResourceUsage::Default };
2505
2509 String Name{ };
2510
2515 size_t AliasingOffset{ 0u };
2516
2517 public:
2522
2530 explicit ResourceAllocationInfo(const BufferInfo& bufferInfo, ResourceUsage usage = ResourceUsage::Default, String name = "", size_t aliasingOffset = 0u) :
2531 ResourceInfo(bufferInfo), Usage(usage), Name(std::move(name)), AliasingOffset(aliasingOffset) { }
2532
2540 explicit ResourceAllocationInfo(const ImageInfo& imageInfo, ResourceUsage usage = ResourceUsage::Default, String name = "", size_t aliasingOffset = 0u) :
2541 ResourceInfo(imageInfo), Usage(usage), Name(std::move(name)), AliasingOffset(aliasingOffset) { }
2542
2546 ResourceAllocationInfo& operator=(ResourceAllocationInfo&&) noexcept = default;
2547 ~ResourceAllocationInfo() noexcept = default;
2548 };
2549
2555 struct LITEFX_RENDERING_API ResourceAllocationResult final {
2556 private:
2558
2559 public:
2565 m_resource(std::move(image)) { }
2566
2572 m_resource(std::move(buffer)) { }
2573
2578 ResourceAllocationResult& operator=(ResourceAllocationResult&&) noexcept = default;
2579 ~ResourceAllocationResult() noexcept = default;
2580
2581 public:
2588 template <std::derived_from<IImage> TImage>
2589 SharedPtr<TImage> image() const {
2590 if (!std::holds_alternative<SharedPtr<IImage>>(m_resource)) [[unlikely]]
2591 throw RuntimeException("The allocation result does not contain an image.");
2592
2593 auto image = std::dynamic_pointer_cast<TImage>(std::get<SharedPtr<IImage>>(m_resource));
2594
2595 if (image == nullptr)
2596 throw RuntimeException("The allocated image resource is not of the requested image type.");
2597
2598 return image;
2599 }
2600
2607 template <std::derived_from<IBuffer> TBuffer>
2609 if (!std::holds_alternative<SharedPtr<IBuffer>>(m_resource)) [[unlikely]]
2610 throw RuntimeException("The allocation result does not contain a buffer.");
2611
2612 auto buffer = std::dynamic_pointer_cast<TBuffer>(std::get<SharedPtr<IBuffer>>(m_resource));
2613
2614 if (buffer == nullptr)
2615 throw RuntimeException("The allocated buffer resource is not of the requested buffer type.");
2616
2617 return buffer;
2618 }
2619 };
2620#pragma endregion
2621
2625 class LITEFX_RENDERING_API IStateResource {
2626 protected:
2627 IStateResource() noexcept = default;
2629 IStateResource(IStateResource&&) noexcept = default;
2630 IStateResource& operator=(const IStateResource&) = delete;
2631 IStateResource& operator=(IStateResource&&) noexcept = default;
2632
2633 public:
2637 virtual ~IStateResource() noexcept = default;
2638
2639 public:
2644 virtual const String& name() const noexcept = 0;
2645 };
2646
2650 class LITEFX_RENDERING_API StateResource : public virtual IStateResource {
2651 LITEFX_IMPLEMENTATION(StateResourceImpl);
2652
2653 protected:
2657 StateResource();
2658
2663 explicit StateResource(StringView name);
2664
2666 StateResource& operator=(StateResource&&) noexcept;
2667
2669 StateResource& operator=(const StateResource&) = delete;
2670
2671 public:
2675 ~StateResource() noexcept override;
2676
2677 protected:
2679 String& name() noexcept;
2680
2681 public:
2683 const String& name() const noexcept override;
2684 };
2685
2697 class LITEFX_RENDERING_API DeviceState {
2698 LITEFX_IMPLEMENTATION(DeviceStateImpl);
2699 friend class IGraphicsDevice;
2700
2701 public:
2705 explicit DeviceState();
2706
2711 DeviceState(DeviceState&& _other) noexcept;
2712
2718 DeviceState& operator=(DeviceState&& _other) noexcept;
2719
2723 virtual ~DeviceState() noexcept;
2724
2725 DeviceState(const DeviceState&) = delete;
2726 DeviceState& operator=(const DeviceState&) = delete;
2727
2728 public:
2732 void clear();
2733
2739 void add(SharedPtr<IRenderPass>&& renderPass);
2740
2747 void add(const String& id, SharedPtr<IRenderPass>&& renderPass);
2748
2754 void add(SharedPtr<IFrameBuffer>&& frameBuffer);
2755
2762 void add(const String& id, SharedPtr<IFrameBuffer>&& frameBuffer);
2763
2769 void add(UniquePtr<IPipeline>&& pipeline);
2770
2777 void add(const String& id, UniquePtr<IPipeline>&& pipeline);
2778
2784 void add(SharedPtr<IBuffer>&& buffer);
2785
2792 void add(const String& id, SharedPtr<IBuffer>&& buffer);
2793
2799 void add(SharedPtr<IVertexBuffer>&& vertexBuffer);
2800
2807 void add(const String& id, SharedPtr<IVertexBuffer>&& vertexBuffer);
2808
2814 void add(SharedPtr<IIndexBuffer>&& indexBuffer);
2815
2822 void add(const String& id, SharedPtr<IIndexBuffer>&& indexBuffer);
2823
2829 void add(SharedPtr<IImage>&& image);
2830
2837 void add(const String& id, SharedPtr<IImage>&& image);
2838
2844 void add(SharedPtr<ISampler>&& sampler);
2845
2852 void add(const String& id, SharedPtr<ISampler>&& sampler);
2853
2859 void add(UniquePtr<IAccelerationStructure>&& accelerationStructure);
2860
2867 void add(const String& id, UniquePtr<IAccelerationStructure>&& accelerationStructure);
2868
2875 void add(const String& id, UniquePtr<IDescriptorSet>&& descriptorSet);
2876
2883 IRenderPass& renderPass(const String& id) const;
2884
2891 IFrameBuffer& frameBuffer(const String& id) const;
2892
2899 IPipeline& pipeline(const String& id) const;
2900
2907 IBuffer& buffer(const String& id) const;
2908
2915 IVertexBuffer& vertexBuffer(const String& id) const;
2916
2923 IIndexBuffer& indexBuffer(const String& id) const;
2924
2931 IImage& image(const String& id) const;
2932
2939 ISampler& sampler(const String& id) const;
2940
2947 IAccelerationStructure& accelerationStructure(const String& id) const;
2948
2955 IDescriptorSet& descriptorSet(const String& id) const;
2956
2967 bool release(const IRenderPass& renderPass);
2968
2974 bool release(const IFrameBuffer& frameBuffer);
2975
2981 bool release(const IPipeline& pipeline);
2982
2988 bool release(const IBuffer& buffer);
2989
2995 bool release(const IVertexBuffer& buffer);
2996
3002 bool release(const IIndexBuffer& buffer);
3003
3009 bool release(const IImage& image);
3010
3016 bool release(const ISampler& sampler);
3017
3023 bool release(const IDescriptorSet& descriptorSet);
3024 };
3025
3032 class LITEFX_RENDERING_API VirtualAllocator final {
3033 public:
3037 struct Allocation final {
3042
3046 UInt64 Size { 0u };
3047
3051 UInt64 Offset { std::numeric_limits<UInt64>::max() };
3052 };
3053
3054 private:
3058 struct AllocatorImplBase {
3059 private:
3060 UInt64 m_size;
3061 AllocationAlgorithm m_algorithm;
3062
3063 protected:
3069 AllocatorImplBase(UInt64 overallMemory, AllocationAlgorithm algorithm) :
3070 m_size(overallMemory), m_algorithm(algorithm)
3071 {
3072 }
3073
3074 AllocatorImplBase(const AllocatorImplBase&) = delete;
3075 AllocatorImplBase(AllocatorImplBase&&) noexcept = delete;
3076 AllocatorImplBase& operator=(const AllocatorImplBase&) = delete;
3077 AllocatorImplBase& operator=(AllocatorImplBase&&) noexcept = delete;
3078
3079 public:
3080 virtual ~AllocatorImplBase() noexcept = default;
3081
3082 public:
3087 inline UInt64 size() const noexcept {
3088 return m_size;
3089 }
3090
3095 inline AllocationAlgorithm algorithm() const noexcept {
3096 return m_algorithm;
3097 }
3098
3107 [[nodiscard]] virtual Allocation allocate(UInt64 size, UInt32 alignment = 1u, AllocationStrategy strategy = AllocationStrategy::OptimizePacking, void* privateData = nullptr) const = 0;
3108
3113 virtual void free(Allocation&& allocation) const = 0;
3114
3120 virtual void* privateData(const Allocation& allocation) const = 0;
3121 };
3122
3127 template <typename TBackend>
3128 struct AllocatorImpl final : public AllocatorImplBase {
3129 static_assert(false, "Attempting to use a non-specialized virtual allocator is invalid.");
3130 };
3131
3136
3141 VirtualAllocator(UniquePtr<AllocatorImplBase>&& pImpl) :
3142 m_impl(std::move(pImpl))
3143 {
3144 }
3145
3146 public:
3149 VirtualAllocator& operator=(const VirtualAllocator&) = delete;
3150 VirtualAllocator& operator=(VirtualAllocator&&) noexcept = delete;
3151 ~VirtualAllocator() noexcept = default;
3152
3153 public:
3160 template <typename TBackend>
3161 [[nodiscard]] static inline VirtualAllocator create(UInt64 overallMemory, AllocationAlgorithm algorithm = AllocationAlgorithm::Default) {
3162 return VirtualAllocator(UniquePtr<AllocatorImplBase>(new AllocatorImpl<TBackend>(overallMemory, algorithm)));
3163 }
3164
3165 public:
3170 inline UInt64 size() const noexcept {
3171 return m_impl->size();
3172 }
3173
3178 inline AllocationAlgorithm algorithm() const noexcept {
3179 return m_impl->algorithm();
3180 }
3181
3190 [[nodiscard]] inline Allocation allocate(UInt64 size, UInt32 alignment = 1u, AllocationStrategy strategy = AllocationStrategy::OptimizePacking, void* privateData = nullptr) const {
3191 return m_impl->allocate(size, alignment, strategy, privateData);
3192 }
3193
3201 inline void free(Allocation&& allocation) const { // NOLINT(cppcoreguidelines-rvalue-reference-param-not-moved)
3202 m_impl->free(std::forward<Allocation>(allocation));
3203 }
3204
3210 inline void* privateData(const Allocation& allocation) const {
3211 return m_impl->privateData(allocation);
3212 };
3213 };
3214
3222 class LITEFX_RENDERING_API IGraphicsAdapter : public SharedObject {
3223 protected:
3224 IGraphicsAdapter() noexcept = default;
3226 IGraphicsAdapter(IGraphicsAdapter&&) noexcept = default;
3227 IGraphicsAdapter& operator=(const IGraphicsAdapter&) = default;
3228 IGraphicsAdapter& operator=(IGraphicsAdapter&&) noexcept = default;
3229
3230 public:
3231 ~IGraphicsAdapter() noexcept override= default;
3232
3233 public:
3238 virtual String name() const = 0;
3239
3244 virtual UInt64 uniqueId() const noexcept = 0;
3245
3250 virtual UInt32 vendorId() const noexcept = 0;
3251
3256 virtual UInt32 deviceId() const noexcept = 0;
3257
3262 virtual GraphicsAdapterType type() const noexcept = 0;
3263
3272 virtual UInt64 driverVersion() const noexcept = 0;
3273
3278 virtual UInt32 apiVersion() const noexcept = 0;
3279
3284 virtual UInt64 dedicatedMemory() const noexcept = 0;
3285 };
3286
3294 class LITEFX_RENDERING_API ISurface {
3295 protected:
3296 ISurface() noexcept = default;
3297 ISurface(const ISurface&) = default;
3298 ISurface(ISurface&&) noexcept = default;
3299 ISurface& operator=(const ISurface&) = default;
3300 ISurface& operator=(ISurface&&) noexcept = default;
3301
3302 public:
3303 virtual ~ISurface() noexcept = default;
3304 };
3305
3309 struct LITEFX_RENDERING_API DescriptorBindingPoint final {
3310 public:
3314 UInt32 Register { 0 };
3315
3319 UInt32 Space { 0 };
3320
3321 public:
3331 inline auto operator<=>(const DescriptorBindingPoint& other) const noexcept {
3332 // NOLINTBEGIN(bugprone-branch-clone)
3333 if (this->Space < other.Space)
3334 return std::strong_ordering::less;
3335 else if (this->Space > other.Space)
3336 return std::strong_ordering::greater;
3337 else if (this->Register < other.Register)
3338 return std::strong_ordering::less;
3339 else if(this->Register > other.Register)
3340 return std::strong_ordering::greater;
3341 else // Space and Register are equal.
3342 return std::strong_ordering::equal;
3343 // NOLINTEND(bugprone-branch-clone)
3344 }
3345
3351 inline bool operator==(const DescriptorBindingPoint& other) const noexcept {
3352 return other.Space == this->Space && other.Register == this->Register;
3353 }
3354 };
3355
3363 class LITEFX_RENDERING_API IShaderModule {
3364 protected:
3365 IShaderModule() noexcept = default;
3366 IShaderModule(const IShaderModule&) = default;
3367 IShaderModule(IShaderModule&&) noexcept = default;
3368 IShaderModule& operator=(const IShaderModule&) = default;
3369 IShaderModule& operator=(IShaderModule&&) noexcept = default;
3370
3371 public:
3372 virtual ~IShaderModule() noexcept = default;
3373
3374 public:
3379 virtual ShaderStage type() const noexcept = 0;
3380
3385 virtual const String& fileName() const noexcept = 0;
3386
3391 virtual const String& entryPoint() const noexcept = 0;
3392
3411 virtual const Optional<DescriptorBindingPoint>& shaderLocalDescriptor() const noexcept = 0;
3412 };
3413
3427 class LITEFX_RENDERING_API IRenderTarget {
3428 public:
3432 struct BlendState {
3433 public:
3437 bool Enable{ false };
3438
3442 BlendFactor SourceColor{ BlendFactor::One };
3443
3447 BlendFactor DestinationColor{ BlendFactor::Zero };
3448
3452 BlendFactor SourceAlpha{ BlendFactor::One };
3453
3457 BlendFactor DestinationAlpha{ BlendFactor::Zero };
3458
3462 BlendOperation ColorOperation{ BlendOperation::Add };
3463
3467 BlendOperation AlphaOperation{ BlendOperation::Add };
3468
3472 WriteMask ChannelWriteMask{ WriteMask::R | WriteMask::G | WriteMask::B | WriteMask::A };
3473 };
3474
3475 protected:
3476 IRenderTarget() noexcept = default;
3477 IRenderTarget(const IRenderTarget&) = default;
3478 IRenderTarget(IRenderTarget&&) noexcept = default;
3479 IRenderTarget& operator=(const IRenderTarget&) = default;
3480 IRenderTarget& operator=(IRenderTarget&&) noexcept = default;
3481
3482 public:
3483 virtual ~IRenderTarget() noexcept = default;
3484
3485 public:
3490 virtual UInt64 identifier() const noexcept = 0;
3491
3496 virtual const String& name() const noexcept = 0;
3497
3506 virtual UInt32 location() const noexcept = 0;
3507
3512 virtual RenderTargetType type() const noexcept = 0;
3513
3518 virtual Format format() const noexcept = 0;
3519
3524 virtual RenderTargetFlags flags() const noexcept = 0;
3525
3535 virtual bool clearBuffer() const noexcept = 0;
3536
3546 virtual bool clearStencil() const noexcept = 0;
3547
3557 virtual const Vector4f& clearValues() const noexcept = 0;
3558
3571 virtual bool isVolatile() const noexcept = 0;
3572
3577 virtual const BlendState& blendState() const noexcept = 0;
3578 };
3579
3584 class LITEFX_RENDERING_API RenderTarget : public IRenderTarget {
3585 LITEFX_IMPLEMENTATION(RenderTargetImpl);
3586
3587 public:
3598 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 = {});
3599
3613 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 = {});
3614
3620
3625 RenderTarget(RenderTarget&& _other) noexcept;
3626
3633
3640
3644 ~RenderTarget() noexcept override;
3645
3646 public:
3648 UInt64 identifier() const noexcept override;
3649
3651 const String& name() const noexcept override;
3652
3654 UInt32 location() const noexcept override;
3655
3657 RenderTargetType type() const noexcept override;
3658
3660 Format format() const noexcept override;
3661
3663 RenderTargetFlags flags() const noexcept override;
3664
3666 bool clearBuffer() const noexcept override;
3667
3669 bool clearStencil() const noexcept override;
3670
3672 const Vector4f& clearValues() const noexcept override;
3673
3675 bool isVolatile() const noexcept override;
3676
3678 const BlendState& blendState() const noexcept override;
3679 };
3680
3684 class LITEFX_RENDERING_API RenderPassDependency {
3685 LITEFX_IMPLEMENTATION(RenderPassDependencyImpl);
3686
3687 public:
3693 RenderPassDependency(const RenderTarget& renderTarget, const DescriptorBindingPoint& descriptorBinding) noexcept;
3694
3701 RenderPassDependency(const RenderTarget& renderTarget, UInt32 bindingRegister, UInt32 space) noexcept;
3702
3708
3714
3721
3728
3733
3734 public:
3739 const RenderTarget& renderTarget() const noexcept;
3740
3745 const DescriptorBindingPoint& binding() const noexcept;
3746 };
3747
3751 class LITEFX_RENDERING_API DepthStencilState final {
3752 LITEFX_IMPLEMENTATION(DepthStencilStateImpl);
3753
3754 public:
3758 struct DepthState {
3759 public:
3763 bool Enable{ true };
3764
3768 bool Write{ true };
3769
3773 CompareOperation Operation{ CompareOperation::Always };
3774
3785 bool DepthBoundsTestEnable{ false };
3786 };
3787
3797 struct DepthBias {
3798 public:
3802 bool Enable{ false };
3803
3807 Float Clamp{ 0.f };
3808
3812 Float SlopeFactor{ 0.f };
3813
3817 Float ConstantFactor{ 0.f };
3818 };
3819
3824 public:
3828 StencilOperation StencilFailOp{ StencilOperation::Keep };
3829
3833 StencilOperation StencilPassOp{ StencilOperation::Replace };
3834
3838 StencilOperation DepthFailOp{ StencilOperation::Keep };
3839
3843 CompareOperation Operation{ CompareOperation::Never };
3844 };
3845
3850 public:
3854 bool Enable{ false };
3855
3859 UInt8 WriteMask{ 0xFF }; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
3860
3864 UInt8 ReadMask{ 0xFF }; // NOLINT(cppcoreguidelines-avoid-magic-numbers)
3865
3869 StencilTest FrontFace{};
3870
3874 StencilTest BackFace{};
3875 };
3876
3877 public:
3884 explicit DepthStencilState(const DepthState& depthState, const DepthBias& depthBias, const StencilState& stencilState) noexcept;
3885
3890
3895
3900
3906
3911 DepthStencilState& operator=(DepthStencilState&&) noexcept;
3912
3916 virtual ~DepthStencilState() noexcept;
3917
3918 public:
3923 virtual DepthState& depthState() const noexcept;
3924
3929 virtual DepthBias& depthBias() const noexcept;
3930
3935 virtual StencilState& stencilState() const noexcept;
3936 };
3937
3941 class LITEFX_RENDERING_API IRasterizer : public SharedObject {
3942 protected:
3943 IRasterizer() noexcept = default;
3944 IRasterizer(const IRasterizer&) = default;
3945 IRasterizer(IRasterizer&&) noexcept = default;
3946 IRasterizer& operator=(const IRasterizer&) = default;
3947 IRasterizer& operator=(IRasterizer&&) noexcept = default;
3948
3949 public:
3950 ~IRasterizer() noexcept override = default;
3951
3952 public:
3957 virtual PolygonMode polygonMode() const noexcept = 0;
3958
3963 virtual CullMode cullMode() const noexcept = 0;
3964
3969 virtual CullOrder cullOrder() const noexcept = 0;
3970
3979 virtual Float lineWidth() const noexcept = 0;
3980
3985 virtual const DepthStencilState& depthStencilState() const noexcept = 0;
3986
3991 virtual bool depthClip() const noexcept = 0;
3992
4000 virtual bool conservativeRasterization() const noexcept = 0;
4001 };
4002
4006 class LITEFX_RENDERING_API Rasterizer : public IRasterizer {
4007 LITEFX_IMPLEMENTATION(RasterizerImpl);
4008
4009 protected:
4020 explicit Rasterizer(PolygonMode polygonMode, CullMode cullMode, CullOrder cullOrder, Float lineWidth = 1.f, bool depthClip = true, const DepthStencilState& depthStencilState = {}, bool conservativeRasterization = false) noexcept;
4021
4026 Rasterizer(const Rasterizer& _other);
4027
4032 Rasterizer(Rasterizer&& _other) noexcept;
4033
4040
4046 Rasterizer& operator=(Rasterizer&& _other) noexcept;
4047
4048 public:
4052 ~Rasterizer() noexcept override;
4053
4054 public:
4056 PolygonMode polygonMode() const noexcept override;
4057
4059 CullMode cullMode() const noexcept override;
4060
4062 CullOrder cullOrder() const noexcept override;
4063
4065 Float lineWidth() const noexcept override;
4066
4068 const DepthStencilState& depthStencilState() const noexcept override;
4069
4071 bool depthClip() const noexcept override;
4072
4074 bool conservativeRasterization() const noexcept override;
4075
4076 protected:
4077 virtual PolygonMode& polygonMode() noexcept;
4078 virtual CullMode& cullMode() noexcept;
4079 virtual CullOrder& cullOrder() noexcept;
4080 virtual Float& lineWidth() noexcept;
4081 virtual bool& depthClip() noexcept;
4082 virtual DepthStencilState& depthStencilState() noexcept;
4083 virtual bool& conservativeRasterization() noexcept;
4084 };
4085
4089 class LITEFX_RENDERING_API IViewport {
4090 protected:
4091 IViewport() noexcept = default;
4092 IViewport(const IViewport&) = default;
4093 IViewport(IViewport&&) noexcept = default;
4094 IViewport& operator=(const IViewport&) = default;
4095 IViewport& operator=(IViewport&&) noexcept = default;
4096
4097 public:
4098 virtual ~IViewport() noexcept = default;
4099
4100 public:
4105 virtual RectF getRectangle() const noexcept = 0;
4106
4111 virtual void setRectangle(const RectF& rectangle) noexcept = 0;
4112
4117 virtual float getMinDepth() const noexcept = 0;
4118
4123 virtual void setMinDepth(Float depth) const noexcept = 0;
4124
4129 virtual float getMaxDepth() const noexcept = 0;
4130
4135 virtual void setMaxDepth(Float depth) const noexcept = 0;
4136 };
4137
4141 class LITEFX_RENDERING_API Viewport : public IViewport {
4142 LITEFX_IMPLEMENTATION(ViewportImpl);
4143
4144 public:
4151 explicit Viewport(const RectF& clientRect = { }, Float minDepth = 0.f, Float maxDepth = 1.f) noexcept;
4152
4157 Viewport(const Viewport& _other);
4158
4163 Viewport(Viewport&& _other) noexcept;
4164
4170 Viewport& operator=(const Viewport& _other);
4171
4177 Viewport& operator=(Viewport&& _other) noexcept;
4178
4182 ~Viewport() noexcept override;
4183
4184 public:
4186 RectF getRectangle() const noexcept override;
4187
4189 void setRectangle(const RectF& rectangle) noexcept override;
4190
4192 Float getMinDepth() const noexcept override;
4193
4195 void setMinDepth(Float depth) const noexcept override;
4196
4198 Float getMaxDepth() const noexcept override;
4199
4201 void setMaxDepth(Float depth) const noexcept override;
4202 };
4203
4207 class LITEFX_RENDERING_API IScissor {
4208 protected:
4209 IScissor() noexcept = default;
4210 IScissor(IScissor&&) noexcept = default;
4211 IScissor(const IScissor&) = default;
4212 IScissor& operator=(IScissor&&) noexcept = default;
4213 IScissor& operator=(const IScissor&) = default;
4214
4215 public:
4216 virtual ~IScissor() noexcept = default;
4217
4218 public:
4223 virtual RectF getRectangle() const noexcept = 0;
4224
4229 virtual void setRectangle(const RectF& rectangle) noexcept = 0;
4230 };
4231
4235 class LITEFX_RENDERING_API Scissor final : public IScissor {
4236 LITEFX_IMPLEMENTATION(ScissorImpl);
4237
4238 public:
4243 explicit Scissor(const RectF& scissorRect = { }) noexcept;
4244
4249 Scissor(const Scissor& _other);
4250
4255 Scissor(Scissor&& _other) noexcept;
4256
4262 Scissor& operator=(const Scissor& _other);
4263
4269 Scissor& operator=(Scissor&& _other) noexcept;
4270
4274 ~Scissor() noexcept override;
4275
4276 public:
4278 RectF getRectangle() const noexcept override;
4279
4281 void setRectangle(const RectF& rectangle) noexcept override;
4282 };
4283
4291 struct LITEFX_RENDERING_API ShaderBindingTableOffsets {
4295 UInt64 RayGenerationGroupOffset { std::numeric_limits<UInt64>::max() };
4296
4300 UInt64 RayGenerationGroupSize { 0 };
4301
4305 UInt64 RayGenerationGroupStride { 0 };
4306
4310 UInt64 HitGroupOffset { std::numeric_limits<UInt64>::max() };
4311
4315 UInt64 HitGroupSize { 0 };
4316
4320 UInt64 HitGroupStride { 0 };
4321
4325 UInt64 MissGroupOffset{ std::numeric_limits<UInt64>::max() };
4326
4330 UInt64 MissGroupSize { 0 };
4331
4335 UInt64 MissGroupStride { 0 };
4336
4340 UInt64 CallableGroupOffset { std::numeric_limits<UInt64>::max() };
4341
4345 UInt64 CallableGroupSize { 0 };
4346
4350 UInt64 CallableGroupStride { 0 };
4351 };
4352
4371 class LITEFX_RENDERING_API TimingEvent final : public SharedObject {
4372 LITEFX_IMPLEMENTATION(TimingEventImpl);
4373 friend class ISwapChain;
4374 friend struct SharedObject::Allocator<TimingEvent>;
4375
4376 private:
4382 explicit TimingEvent(const ISwapChain& swapChain, StringView name = "");
4383
4384 public:
4388 ~TimingEvent() noexcept override;
4389
4390 TimingEvent(TimingEvent&&) noexcept = delete;
4391 TimingEvent(const TimingEvent&) = delete;
4392 auto operator=(TimingEvent&&) noexcept = delete;
4393 auto operator=(const TimingEvent&) = delete;
4394
4395 private:
4402 static inline auto create(const ISwapChain& swapChain, StringView name = "") {
4403 return SharedObject::create<TimingEvent>(swapChain, name);
4404 }
4405
4406 public:
4411 StringView name() const noexcept;
4412
4423 UInt64 readTimestamp() const;
4424
4431 UInt32 queryId() const;
4432 };
4433
4437 class LITEFX_RENDERING_API BufferAttribute final {
4438 LITEFX_IMPLEMENTATION(BufferAttributeImpl);
4439
4440 public:
4444 BufferAttribute() noexcept;
4445
4454 BufferAttribute(UInt32 location, UInt32 offset, BufferFormat format, AttributeSemantic semantic, UInt32 semanticIndex = 0) noexcept;
4455
4461
4467
4474
4481
4485 virtual ~BufferAttribute() noexcept;
4486
4487 public:
4495 virtual UInt32 location() const noexcept;
4496
4501 virtual BufferFormat format() const noexcept;
4502
4507 virtual UInt32 offset() const noexcept;
4508
4517 virtual AttributeSemantic semantic() const noexcept;
4518
4527 virtual UInt32 semanticIndex() const noexcept;
4528 };
4529
4536 class LITEFX_RENDERING_API IBufferLayout {
4537 protected:
4538 IBufferLayout() noexcept = default;
4539 IBufferLayout(IBufferLayout&&) noexcept = default;
4540 IBufferLayout(const IBufferLayout&) = default;
4541 IBufferLayout& operator=(IBufferLayout&&) noexcept = default;
4542 IBufferLayout& operator=(const IBufferLayout&) = default;
4543
4544 public:
4545 virtual ~IBufferLayout() noexcept = default;
4546
4547 public:
4552 virtual size_t elementSize() const noexcept = 0;
4553
4561 virtual UInt32 binding() const noexcept = 0;
4562
4567 virtual BufferType type() const noexcept = 0;
4568 };
4569
4574 class LITEFX_RENDERING_API IVertexBufferLayout : public IBufferLayout, public SharedObject {
4575 protected:
4576 IVertexBufferLayout() noexcept = default;
4579 IVertexBufferLayout& operator=(IVertexBufferLayout&&) noexcept = default;
4580 IVertexBufferLayout& operator=(const IVertexBufferLayout&) = default;
4581
4582 public:
4583 ~IVertexBufferLayout() noexcept override = default;
4584
4585 public:
4590 virtual const Array<BufferAttribute>& attributes() const = 0;
4591
4596 virtual VertexBufferInputRate inputRate() const noexcept = 0;
4597 };
4598
4603 class LITEFX_RENDERING_API IIndexBufferLayout : public IBufferLayout, public SharedObject {
4604 protected:
4605 IIndexBufferLayout() noexcept = default;
4608 IIndexBufferLayout& operator=(IIndexBufferLayout&&) noexcept = default;
4609 IIndexBufferLayout& operator=(const IIndexBufferLayout&) = default;
4610
4611 public:
4612 ~IIndexBufferLayout() noexcept override = default;
4613
4614 public:
4619 virtual IndexType indexType() const noexcept = 0;
4620 };
4621
4641 class LITEFX_RENDERING_API IDescriptorLayout : public IBufferLayout {
4642 protected:
4643 IDescriptorLayout() noexcept = default;
4646 IDescriptorLayout& operator=(IDescriptorLayout&&) noexcept = default;
4647 IDescriptorLayout& operator=(const IDescriptorLayout&) = default;
4648
4649 public:
4650 ~IDescriptorLayout() noexcept override = default;
4651
4652 public:
4657 virtual DescriptorType descriptorType() const noexcept = 0;
4658
4668 virtual UInt32 descriptors() const noexcept = 0;
4669
4675 virtual bool unbounded() const noexcept = 0;
4676
4686 virtual const ISampler* staticSampler() const noexcept = 0;
4687 };
4688
4692 class LITEFX_RENDERING_API IMappable {
4693 protected:
4694 IMappable() noexcept = default;
4695 IMappable(IMappable&&) noexcept = default;
4696 IMappable(const IMappable&) = default;
4697 IMappable& operator=(IMappable&&) noexcept = default;
4698 IMappable& operator=(const IMappable&) = default;
4699
4700 public:
4701 virtual ~IMappable() noexcept = default;
4702
4703 public:
4710 virtual void map(const void* const data, size_t size, UInt32 element = 0) = 0;
4711
4718 virtual void map(Span<const void* const> data, size_t elementSize, UInt32 firstElement = 0) = 0;
4719
4727 virtual void map(void* data, size_t size, UInt32 element = 0, bool write = true) = 0;
4728
4736 virtual void map(Span<void*> data, size_t elementSize, UInt32 firstElement = 0, bool write = true) = 0;
4737
4744 virtual void write(const void* const data, size_t size, size_t offset = 0) = 0;
4745
4752 virtual void read(void* data, size_t size, size_t offset = 0) = 0;
4753 };
4754
4758 class LITEFX_RENDERING_API IDeviceMemory {
4759 public:
4765 private:
4769 IBarrier& m_barrier;
4770
4771 public:
4775 PrepareMoveEventArgs& operator=(const PrepareMoveEventArgs&) = delete;
4776 PrepareMoveEventArgs& operator=(PrepareMoveEventArgs&&) noexcept = delete;
4777 ~PrepareMoveEventArgs() noexcept = default;
4778
4784 m_barrier(barrier) {
4785 }
4786
4787 public:
4792 IBarrier& barrier() const noexcept {
4793 return m_barrier;
4794 }
4795 };
4796
4802 private:
4804 UInt64 m_fence{};
4805
4806 public:
4813 m_queue(std::move(queue)), m_fence(fence)
4814 {
4815 }
4816
4820 ResourceMovingEventArgs& operator=(ResourceMovingEventArgs&&) noexcept = default;
4821 ~ResourceMovingEventArgs() noexcept = default;
4822
4823 public:
4828 SharedPtr<const ICommandQueue> queue() const noexcept {
4829 return m_queue;
4830 }
4831
4836 UInt64 fence() const noexcept {
4837 return m_fence;
4838 }
4839 };
4840
4841 protected:
4842 IDeviceMemory() noexcept = default;
4843 IDeviceMemory(IDeviceMemory&&) noexcept = default;
4844 IDeviceMemory(const IDeviceMemory&) = default;
4845 IDeviceMemory& operator=(IDeviceMemory&&) noexcept = default;
4846 IDeviceMemory& operator=(const IDeviceMemory&) = default;
4847
4848 public:
4849 virtual ~IDeviceMemory() noexcept = default;
4850
4851 public:
4864 mutable Event<const PrepareMoveEventArgs&> prepareMove;
4865
4880
4894 mutable Event<EventArgs> moved;
4895
4896 public:
4906 virtual UInt32 elements() const noexcept = 0;
4907
4921 virtual size_t size() const noexcept = 0;
4922
4932 virtual size_t elementSize() const noexcept = 0;
4933
4940 virtual size_t elementAlignment() const noexcept = 0;
4941
4951 virtual size_t alignedElementSize() const noexcept = 0;
4952
4957 virtual ResourceUsage usage() const noexcept = 0;
4958
4966 virtual UInt64 virtualAddress() const noexcept = 0;
4967
4975 virtual inline bool writable() const noexcept {
4976 return LITEFX_FLAG_IS_SET(this->usage(), ResourceUsage::AllowWrite);
4977 }
4978
4989 virtual inline bool volatileMove() const noexcept {
4990 return LITEFX_FLAG_IS_SET(this->usage(), ResourceUsage::Volatile);
4991 }
4992 };
4993
4997 class LITEFX_RENDERING_API IBuffer : public virtual IDeviceMemory, public virtual IMappable, public virtual IStateResource, public SharedObject {
4998 protected:
4999 IBuffer() noexcept = default;
5000 IBuffer(IBuffer&&) noexcept = default;
5001 IBuffer(const IBuffer&) = delete;
5002 IBuffer& operator=(IBuffer&&) noexcept = default;
5003 IBuffer& operator=(const IBuffer&) = delete;
5004
5005 public:
5006 ~IBuffer() noexcept override = default;
5007
5008 public:
5013 virtual BufferType type() const noexcept = 0;
5014 };
5015
5019 class LITEFX_RENDERING_API IImage : public virtual IDeviceMemory, public virtual IStateResource, public SharedObject {
5020 public:
5021 using IDeviceMemory::size;
5022
5023 protected:
5024 IImage() noexcept = default;
5025 IImage(IImage&&) noexcept = default;
5026 IImage(const IImage&) = delete;
5027 IImage& operator=(IImage&&) noexcept = default;
5028 IImage& operator=(const IImage&) = delete;
5029
5030 public:
5031 ~IImage() noexcept override = default;
5032
5033 public:
5043 virtual size_t size(UInt32 level) const noexcept = 0;
5044
5054 virtual Size3d extent(UInt32 level = 0) const noexcept = 0;
5055
5060 virtual Format format() const noexcept = 0;
5061
5070 virtual ImageDimensions dimensions() const noexcept = 0;
5071
5076 virtual UInt32 levels() const noexcept = 0;
5077
5082 virtual UInt32 layers() const noexcept = 0;
5083
5092 virtual UInt32 planes() const noexcept = 0;
5093
5098 virtual MultiSamplingLevel samples() const noexcept = 0;
5099
5100 // TODO: getSampler() for combined samplers?
5101
5102 public:
5111 virtual inline UInt32 subresourceId(UInt32 level, UInt32 layer, UInt32 plane) const noexcept {
5112 return level + (layer * this->levels()) + (plane * this->levels() * this->layers());
5113 }
5114
5123 virtual inline void resolveSubresource(UInt32 subresource, UInt32& plane, UInt32& layer, UInt32& level) const noexcept {
5124 const auto levels = this->levels();
5125 const UInt32 resourcesPerPlane = levels * this->layers();
5126 plane = subresource / resourcesPerPlane;
5127 layer = (subresource % resourcesPerPlane) / levels;
5128 level = subresource % levels;
5129 }
5130 };
5131
5135 class LITEFX_RENDERING_API ISampler : public virtual IStateResource, public SharedObject {
5136 protected:
5137 ISampler() noexcept = default;
5138 ISampler(ISampler&&) noexcept = default;
5139 ISampler(const ISampler&) = delete;
5140 ISampler& operator=(ISampler&&) noexcept = default;
5141 ISampler& operator=(const ISampler&) = delete;
5142
5143 public:
5144 ~ISampler() noexcept override = default;
5145
5146 public:
5151 virtual FilterMode getMinifyingFilter() const noexcept = 0;
5152
5157 virtual FilterMode getMagnifyingFilter() const noexcept = 0;
5158
5163 virtual BorderMode getBorderModeU() const noexcept = 0;
5164
5169 virtual BorderMode getBorderModeV() const noexcept = 0;
5170
5175 virtual BorderMode getBorderModeW() const noexcept = 0;
5176
5184 virtual Float getAnisotropy() const noexcept = 0;
5185
5190 virtual MipMapMode getMipMapMode() const noexcept = 0;
5191
5196 virtual Float getMipMapBias() const noexcept = 0;
5197
5202 virtual Float getMaxLOD() const noexcept = 0;
5203
5208 virtual Float getMinLOD() const noexcept = 0;
5209 };
5210
5214 class LITEFX_RENDERING_API IVertexBuffer : public virtual IBuffer {
5215 protected:
5216 IVertexBuffer() noexcept = default;
5218 IVertexBuffer(IVertexBuffer&&) noexcept = default;
5219 IVertexBuffer& operator=(const IVertexBuffer&) = delete;
5220 IVertexBuffer& operator=(IVertexBuffer&&) noexcept = default;
5221
5222 public:
5223 ~IVertexBuffer() noexcept override = default;
5224
5225 public:
5230 virtual const IVertexBufferLayout& layout() const noexcept = 0;
5231 };
5232
5236 class LITEFX_RENDERING_API IIndexBuffer : public virtual IBuffer {
5237 protected:
5238 IIndexBuffer() noexcept = default;
5239 IIndexBuffer(const IIndexBuffer&) = delete;
5240 IIndexBuffer(IIndexBuffer&&) noexcept = default;
5241 IIndexBuffer& operator=(const IIndexBuffer&) = delete;
5242 IIndexBuffer& operator=(IIndexBuffer&&) noexcept = default;
5243
5244 public:
5245 ~IIndexBuffer() noexcept override = default;
5246
5247 public:
5252 virtual const IIndexBufferLayout& layout() const noexcept = 0;
5253 };
5254
5260 class LITEFX_RENDERING_API IAccelerationStructure : public virtual IStateResource {
5261 protected:
5262 IAccelerationStructure() noexcept = default;
5265 IAccelerationStructure& operator=(IAccelerationStructure&&) noexcept = default;
5267
5268 public:
5269 ~IAccelerationStructure() noexcept override = default;
5270
5271 public:
5276 virtual AccelerationStructureFlags flags() const noexcept = 0;
5277
5305 inline void build(const ICommandBuffer& commandBuffer, const SharedPtr<const IBuffer>& scratchBuffer = nullptr, const SharedPtr<const IBuffer>& buffer = nullptr, UInt64 offset = 0, UInt64 maxSize = 0) {
5306 this->doBuild(commandBuffer, scratchBuffer, buffer, offset, maxSize);
5307 }
5308
5341 inline void update(const ICommandBuffer& commandBuffer, const SharedPtr<const IBuffer>& scratchBuffer = nullptr, const SharedPtr<const IBuffer>& buffer = nullptr, UInt64 offset = 0, UInt64 maxSize = 0) {
5342 this->doUpdate(commandBuffer, scratchBuffer, buffer, offset, maxSize);
5343 }
5344
5351 inline SharedPtr<const IBuffer> buffer() const noexcept {
5352 return this->getBuffer();
5353 }
5354
5360 virtual UInt64 offset() const noexcept = 0;
5361
5376 virtual UInt64 size() const noexcept = 0;
5377
5378 private:
5379 virtual SharedPtr<const IBuffer> getBuffer() const noexcept = 0;
5380 virtual void doBuild(const ICommandBuffer& commandBuffer, const SharedPtr<const IBuffer>& scratchBuffer, const SharedPtr<const IBuffer>& buffer, UInt64 offset, UInt64 maxSize) = 0;
5381 virtual void doUpdate(const ICommandBuffer& commandBuffer, const SharedPtr<const IBuffer>& scratchBuffer, const SharedPtr<const IBuffer>& buffer, UInt64 offset, UInt64 maxSize) = 0;
5382 };
5383
5399 class LITEFX_RENDERING_API IBottomLevelAccelerationStructure : public virtual IAccelerationStructure {
5400 public:
5404 struct TriangleMesh final {
5405 public:
5413 TriangleMesh(const SharedPtr<const IVertexBuffer>& vertexBuffer, const SharedPtr<const IIndexBuffer>& indexBuffer = nullptr, const SharedPtr<const IBuffer>& transformBuffer = nullptr, GeometryFlags flags = GeometryFlags::None) :
5414 VertexBuffer(vertexBuffer), IndexBuffer(indexBuffer), TransformBuffer(transformBuffer), Flags(flags) {
5415 if (vertexBuffer == nullptr) [[unlikely]]
5416 throw ArgumentNotInitializedException("vertexBuffer", "The vertex buffer must be initialized.");
5417 }
5418
5423 TriangleMesh(TriangleMesh&& other) noexcept = default;
5424
5429 TriangleMesh(const TriangleMesh& other) = default;
5430
5436 TriangleMesh& operator=(TriangleMesh&& other) noexcept = default;
5437
5443 TriangleMesh& operator=(const TriangleMesh& other) = default;
5444
5448 ~TriangleMesh() noexcept = default;
5449
5450 public:
5455
5460
5467 SharedPtr<const IBuffer> TransformBuffer;
5468
5473 };
5474
5505
5506 protected:
5512
5513 public:
5514 ~IBottomLevelAccelerationStructure() noexcept override = default;
5515
5516 public:
5521 virtual const Array<TriangleMesh>& triangleMeshes() const noexcept = 0;
5522
5528 virtual void addTriangleMesh(const TriangleMesh& mesh) = 0;
5529
5538 inline void addTriangleMesh(const SharedPtr<const IVertexBuffer>& vertexBuffer, const SharedPtr<const IIndexBuffer>& indexBuffer = nullptr, const SharedPtr<const IBuffer>& transformBuffer = nullptr, GeometryFlags flags = GeometryFlags::None) {
5539 this->addTriangleMesh(TriangleMesh(vertexBuffer, indexBuffer, transformBuffer, flags));
5540 }
5541
5546 virtual const Array<BoundingBoxes>& boundingBoxes() const noexcept = 0;
5547
5553 virtual void addBoundingBox(const BoundingBoxes& aabbs) = 0;
5554
5561 inline void addBoundingBox(const SharedPtr<const IBuffer>& buffer, GeometryFlags flags = GeometryFlags::None) {
5562 this->addBoundingBox(BoundingBoxes { .Buffer = buffer, .Flags = flags });
5563 }
5564
5568 virtual void clear() noexcept = 0;
5569
5575 virtual bool remove(const TriangleMesh& mesh) noexcept = 0;
5576
5582 virtual bool remove(const BoundingBoxes& aabb) noexcept = 0;
5583
5618 inline void copy(const ICommandBuffer& commandBuffer, IBottomLevelAccelerationStructure& destination, bool compress = false, const SharedPtr<const IBuffer>& buffer = nullptr, UInt64 offset = 0, bool copyBuildInfo = true) const {
5619 this->doCopy(commandBuffer, destination, compress, buffer, offset, copyBuildInfo);
5620 }
5621
5622 public:
5629 template <typename TSelf>
5630 inline auto withTriangleMesh(this TSelf&& self, const TriangleMesh& mesh) -> TSelf&& {
5631 self.addTriangleMesh(mesh);
5632 return std::forward<TSelf>(self);
5633 }
5634
5644 template <typename TSelf>
5645 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&& {
5646 return std::forward<TSelf>(self).withTriangleMesh(TriangleMesh(vertexBuffer, indexBuffer, transformBuffer, flags));
5647 }
5648
5655 template <typename TSelf>
5656 inline auto withBoundingBox(this TSelf&& self, const BoundingBoxes& aabb) -> TSelf&& {
5657 self.addBoundingBox(aabb);
5658 return std::forward<TSelf>(self);
5659 }
5660
5668 template <typename TSelf>
5669 inline auto withBoundingBox(this TSelf&& self, const SharedPtr<const IBuffer>& buffer, GeometryFlags flags = GeometryFlags::None) -> TSelf&& {
5670 return std::forward<TSelf>(self).withBoundingBox(BoundingBoxes { .Buffer = buffer, .Flags = flags });
5671 }
5672
5673 private:
5674 virtual void doCopy(const ICommandBuffer& commandBuffer, IBottomLevelAccelerationStructure& destination, bool compress, const SharedPtr<const IBuffer>& buffer, UInt64 offset, bool copyBuildInfo) const = 0;
5675 };
5676
5681 class LITEFX_RENDERING_API ITopLevelAccelerationStructure : public virtual IAccelerationStructure {
5682 public:
5683#pragma warning(push)
5684#pragma warning(disable: 4324) // Structure was padded due to alignment specifier
5688 struct alignas(16) Instance final { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
5692 SharedPtr<const IBottomLevelAccelerationStructure> BottomLevelAccelerationStructure;
5693
5698
5702 UInt32 Id : 24 = 0;
5703
5707 UInt8 Mask : 8 = 0xFF;
5708
5724
5728 InstanceFlags Flags : 8 = InstanceFlags::None;
5729 };
5730#pragma warning(pop)
5731
5732 protected:
5738
5739 public:
5740 ~ITopLevelAccelerationStructure() noexcept override = default;
5741
5742 public:
5747 virtual const Array<Instance>& instances() const noexcept = 0;
5748
5754 virtual void addInstance(const Instance& instance) = 0;
5755
5764 inline void addInstance(const SharedPtr<const IBottomLevelAccelerationStructure>& blas, UInt32 id, UInt32 hitGroupOffset = 0, UInt8 mask = 0xFF, InstanceFlags flags = InstanceFlags::None) noexcept { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
5765 this->addInstance(Instance { .BottomLevelAccelerationStructure = blas, .Id = id, .Mask = mask, .HitGroupOffset = hitGroupOffset, .Flags = flags });
5766 }
5767
5777 inline void addInstance(const SharedPtr<const IBottomLevelAccelerationStructure>& blas, const TMatrix3x4<Float>& transform, UInt32 id, UInt32 hitGroupOffset = 0, UInt8 mask = 0xFF, InstanceFlags flags = InstanceFlags::None) noexcept { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
5778 this->addInstance(Instance { .BottomLevelAccelerationStructure = blas, .Transform = transform, .Id = id, .Mask = mask, .HitGroupOffset = hitGroupOffset, .Flags = flags });
5779 }
5780
5784 virtual void clear() noexcept = 0;
5785
5791 virtual bool remove(const Instance& instance) noexcept = 0;
5792
5827 inline void copy(const ICommandBuffer& commandBuffer, ITopLevelAccelerationStructure& destination, bool compress = false, const SharedPtr<const IBuffer>& buffer = nullptr, UInt64 offset = 0, bool copyBuildInfo = true) const {
5828 this->doCopy(commandBuffer, destination, compress, buffer, offset, copyBuildInfo);
5829 }
5830
5831 public:
5837 template<typename TSelf>
5838 inline auto withInstance(this TSelf&& self, const Instance& instance) noexcept -> TSelf&& {
5839 self.addInstance(instance);
5840 return std::forward<TSelf>(self);
5841 }
5842
5852 template<typename TSelf>
5853 inline auto withInstance(this TSelf&& self, const SharedPtr<const IBottomLevelAccelerationStructure>& blas, UInt32 id, UInt32 hitGroupOffset = 0, UInt8 mask = 0xFF, InstanceFlags flags = InstanceFlags::None) noexcept -> TSelf&& { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
5854 self.addInstance(Instance { .BottomLevelAccelerationStructure = blas, .Id = id, .Mask = mask, .HitGroupOffset = hitGroupOffset, .Flags = flags });
5855 return std::forward<TSelf>(self);
5856 }
5857
5868 template<typename TSelf>
5869 inline auto withInstance(this TSelf&& self, const SharedPtr<const IBottomLevelAccelerationStructure>& blas, const TMatrix3x4<Float>& transform, UInt32 id, UInt32 hitGroupOffset = 0, UInt8 mask = 0xFF, InstanceFlags flags = InstanceFlags::None) noexcept -> TSelf&& { // NOLINT(cppcoreguidelines-avoid-magic-numbers)
5870 self.addInstance(Instance { .BottomLevelAccelerationStructure = blas, .Transform = transform, .Id = id, .Mask = mask, .HitGroupOffset = hitGroupOffset, .Flags = flags });
5871 return std::forward<TSelf>(self);
5872 }
5873
5874 private:
5875 virtual void doCopy(const ICommandBuffer& commandBuffer, ITopLevelAccelerationStructure& destination, bool compress, const SharedPtr<const IBuffer>& buffer, UInt64 offset, bool copyBuildInfo) const = 0;
5876 };
5877
5921 class LITEFX_RENDERING_API IBarrier {
5922 protected:
5923 IBarrier() noexcept = default;
5924 IBarrier(const IBarrier&) = default;
5925 IBarrier(IBarrier&&) noexcept = default;
5926 IBarrier& operator=(const IBarrier&) = default;
5927 IBarrier& operator=(IBarrier&&) noexcept = default;
5928
5929 public:
5930 virtual ~IBarrier() noexcept = default;
5931
5932 public:
5937 constexpr virtual PipelineStage syncBefore() const noexcept = 0;
5938
5943 constexpr virtual PipelineStage syncAfter() const noexcept = 0;
5944
5951 constexpr virtual void wait(ResourceAccess accessBefore, ResourceAccess accessAfter) = 0;
5952
5960 constexpr void transition(const IBuffer& buffer, ResourceAccess accessBefore, ResourceAccess accessAfter) {
5961 this->doTransition(buffer, accessBefore, accessAfter);
5962 };
5963
5976 constexpr void transition(const IBuffer& buffer, UInt32 element, ResourceAccess accessBefore, ResourceAccess accessAfter) {
5977 this->doTransition(buffer, element, accessBefore, accessAfter);
5978 }
5979
5989 constexpr void transition(const IImage& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) {
5990 this->doTransition(image, accessBefore, accessAfter, layout);
5991 }
5992
6007 constexpr void transition(const IImage& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) {
6008 this->doTransition(image, level, levels, layer, layers, plane, accessBefore, accessAfter, layout);
6009 }
6010
6025 constexpr void transition(const IImage& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) {
6026 this->doTransition(image, accessBefore, accessAfter, fromLayout, toLayout);
6027 }
6028
6048 constexpr void transition(const IImage& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) {
6049 this->doTransition(image, level, levels, layer, layers, plane, accessBefore, accessAfter, fromLayout, toLayout);
6050 }
6051
6052 private:
6053 constexpr virtual void doTransition(const IBuffer& buffer, ResourceAccess accessBefore, ResourceAccess accessAfter) = 0;
6054 constexpr virtual void doTransition(const IBuffer& buffer, UInt32 element, ResourceAccess accessBefore, ResourceAccess accessAfter) = 0;
6055 constexpr virtual void doTransition(const IImage& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) = 0;
6056 constexpr virtual void doTransition(const IImage& image, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout fromLayout, ImageLayout toLayout) = 0;
6057 constexpr virtual void doTransition(const IImage& image, UInt32 level, UInt32 levels, UInt32 layer, UInt32 layers, UInt32 plane, ResourceAccess accessBefore, ResourceAccess accessAfter, ImageLayout layout) = 0;
6058 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;
6059 };
6060
6064 class LITEFX_RENDERING_API IDescriptorSet {
6065 protected:
6066 IDescriptorSet() noexcept = default;
6068 IDescriptorSet(IDescriptorSet&&) noexcept = default;
6069 IDescriptorSet& operator=(const IDescriptorSet&) = default;
6070 IDescriptorSet& operator=(IDescriptorSet&&) noexcept = default;
6071
6072 public:
6073 virtual ~IDescriptorSet() noexcept = default;
6074
6075 public:
6081 virtual VirtualAllocator::Allocation globalHeapAllocation(DescriptorHeapType heapType) const noexcept = 0;
6082
6101 inline UInt32 bindToHeap(DescriptorType bindingType, UInt32 descriptor, const IBuffer& buffer, UInt32 bufferElement = 0, UInt32 elements = 0, Format texelFormat = Format::None) const {
6102 return this->doBind(bindingType, descriptor, buffer, bufferElement, elements, texelFormat);
6103 }
6104
6124 inline UInt32 bindToHeap(DescriptorType bindingType, UInt32 descriptor, const IImage& image, UInt32 firstLevel = 0, UInt32 levels = 0, UInt32 firstLayer = 0, UInt32 layers = 0) const {
6125 return this->doBind(bindingType, descriptor, image, firstLevel, levels, firstLayer, layers);
6126 }
6127
6141 inline UInt32 bindToHeap(UInt32 descriptor, const ISampler& sampler) const {
6142 return this->doBind(descriptor, sampler);
6143 }
6144
6154 inline void update(UInt32 binding, const IBuffer& buffer, UInt32 bufferElement = 0, UInt32 elements = 0, UInt32 firstDescriptor = 0, Format texelFormat = Format::None) const {
6155 this->doUpdate(binding, buffer, bufferElement, elements, firstDescriptor, texelFormat);
6156 }
6157
6179 inline void update(UInt32 binding, const IImage& texture, UInt32 descriptor = 0, UInt32 firstLevel = 0, UInt32 levels = 0, UInt32 firstLayer = 0, UInt32 layers = 0) const {
6180 this->doUpdate(binding, texture, descriptor, firstLevel, levels, firstLayer, layers);
6181 }
6182
6189 inline void update(UInt32 binding, const ISampler& sampler, UInt32 descriptor = 0) const {
6190 this->doUpdate(binding, sampler, descriptor);
6191 }
6192
6199 inline void update(UInt32 binding, const IAccelerationStructure& accelerationStructure, UInt32 descriptor = 0) const {
6200 this->doUpdate(binding, accelerationStructure, descriptor);
6201 }
6202
6203 private:
6204 virtual UInt32 doBind(DescriptorType bindingType, UInt32 descriptor, const IBuffer& buffer, UInt32 bufferElement, UInt32 elements, Format texelFormat) const = 0;
6205 virtual UInt32 doBind(DescriptorType bindingType, UInt32 descriptor, const IImage& image, UInt32 firstLevel, UInt32 levels, UInt32 firstLayer, UInt32 layers) const = 0;
6206 virtual UInt32 doBind(UInt32 descriptor, const ISampler& sampler) const = 0;
6207 virtual void doUpdate(UInt32 binding, const IBuffer& buffer, UInt32 bufferElement, UInt32 elements, UInt32 firstDescriptor, Format texelFormat) const = 0;
6208 virtual void doUpdate(UInt32 binding, const IImage& texture, UInt32 descriptor, UInt32 firstLevel, UInt32 levels, UInt32 firstLayer, UInt32 layers) const = 0;
6209 virtual void doUpdate(UInt32 binding, const ISampler& sampler, UInt32 descriptor) const = 0;
6210 virtual void doUpdate(UInt32 binding, const IAccelerationStructure& accelerationStructure, UInt32 descriptor) const = 0;
6211 };
6212
6218 struct LITEFX_RENDERING_API DescriptorBinding {
6219 public:
6221
6222 public:
6226 Optional<UInt32> binding = std::nullopt;
6227
6239 resource_container resource = {};
6240
6250 UInt32 firstDescriptor = 0;
6251
6259 UInt32 firstElement = 0;
6260
6268 UInt32 elements = 0;
6269
6276 UInt32 firstLevel = 0;
6277
6284 UInt32 levels = 0;
6285 };
6286
6290 class LITEFX_RENDERING_API IDescriptorSetLayout : public SharedObject {
6291 protected:
6292 IDescriptorSetLayout() noexcept = default;
6295 IDescriptorSetLayout& operator=(const IDescriptorSetLayout&) = default;
6296 IDescriptorSetLayout& operator=(IDescriptorSetLayout&&) noexcept = default;
6297
6298 public:
6299 ~IDescriptorSetLayout() noexcept override = default;
6300
6301 public:
6306 inline Enumerable<const IDescriptorLayout&> descriptors() const noexcept {
6307 return this->getDescriptors();
6308 }
6309
6315 virtual const IDescriptorLayout& descriptor(UInt32 binding) const = 0;
6316
6324 virtual UInt32 space() const noexcept = 0;
6325
6330 virtual ShaderStage shaderStages() const noexcept = 0;
6331
6336 virtual UInt32 uniforms() const noexcept = 0;
6337
6342 virtual UInt32 storages() const noexcept = 0;
6343
6348 virtual UInt32 images() const noexcept = 0;
6349
6354 virtual UInt32 buffers() const noexcept = 0;
6355
6361 virtual UInt32 samplers() const noexcept = 0;
6362
6368 virtual UInt32 staticSamplers() const noexcept = 0;
6369
6374 virtual UInt32 inputAttachments() const noexcept = 0;
6375
6380 virtual bool containsUnboundedArray() const noexcept = 0;
6381
6388 virtual UInt32 getDescriptorOffset(UInt32 binding, UInt32 element = 0) const = 0;
6389
6394 virtual bool bindsResources() const noexcept = 0;
6395
6403 virtual bool bindsSamplers() const noexcept = 0;
6404
6405 public:
6435 inline UniquePtr<IDescriptorSet> allocate(std::initializer_list<DescriptorBinding> bindings = { }) const {
6436 return this->getDescriptorSet(0, bindings);
6437 }
6438
6441 return this->getDescriptorSet(0, bindings);
6442 }
6443
6446 return this->getDescriptorSet(0, std::move(bindings));
6447 }
6448
6457 inline UniquePtr<IDescriptorSet> allocate(UInt32 descriptors, std::initializer_list<DescriptorBinding> bindings) const {
6458 return this->getDescriptorSet(descriptors, bindings);
6459 }
6460
6463 return this->getDescriptorSet(descriptors, bindings);
6464 }
6465
6474 return this->getDescriptorSet(descriptors, std::move(bindings));
6475 }
6476
6484 inline Generator<UniquePtr<IDescriptorSet>> allocate(UInt32 descriptorSets, std::initializer_list<std::initializer_list<DescriptorBinding>> bindings = { }) const {
6485 return this->getDescriptorSets(descriptorSets, 0, bindings);
6486 }
6487
6488#ifdef __cpp_lib_mdspan
6490 inline Generator<UniquePtr<IDescriptorSet>> allocate(UInt32 descriptorSets, std::mdspan<DescriptorBinding, std::dextents<size_t, 2>> bindings) const {
6491 return this->getDescriptorSets(descriptorSets, 0, bindings);
6492 }
6493#endif
6494
6502 inline Generator<UniquePtr<IDescriptorSet>> allocate(UInt32 descriptorSets, std::function<Generator<DescriptorBinding>(UInt32)> bindingFactory) const {
6503 return this->getDescriptorSets(descriptorSets, 0, std::move(bindingFactory));
6504 }
6505
6514 inline Generator<UniquePtr<IDescriptorSet>> allocate(UInt32 descriptorSets, UInt32 descriptors, std::initializer_list<std::initializer_list<DescriptorBinding>> bindings = { }) const {
6515 return this->getDescriptorSets(descriptorSets, descriptors, bindings);
6516 }
6517
6518#ifdef __cpp_lib_mdspan
6520 inline Generator<UniquePtr<IDescriptorSet>> allocate(UInt32 descriptorSets, UInt32 descriptors, std::mdspan<DescriptorBinding, std::dextents<size_t, 2>> bindings) const {
6521 return this->getDescriptorSets(descriptorSets, descriptors, bindings);
6522 }
6523#endif
6524
6533 inline Generator<UniquePtr<IDescriptorSet>> allocate(UInt32 descriptorSets, UInt32 descriptors, std::function<Generator<DescriptorBinding>(UInt32)> bindingFactory) const {
6534 return this->getDescriptorSets(descriptorSets, descriptors, std::move(bindingFactory));
6535 }
6536
6541 inline void free(const IDescriptorSet& descriptorSet) const {
6542 this->releaseDescriptorSet(descriptorSet);
6543 }
6544
6545 private:
6546 virtual Enumerable<const IDescriptorLayout&> getDescriptors() const noexcept = 0;
6547 virtual UniquePtr<IDescriptorSet> getDescriptorSet(UInt32 descriptors, std::initializer_list<DescriptorBinding> bindings) const = 0;
6548 virtual UniquePtr<IDescriptorSet> getDescriptorSet(UInt32 descriptors, Span<DescriptorBinding> bindings) const = 0;
6549 virtual UniquePtr<IDescriptorSet> getDescriptorSet(UInt32 descriptors, Generator<DescriptorBinding> bindings) const = 0;
6550 virtual Generator<UniquePtr<IDescriptorSet>> getDescriptorSets(UInt32 descriptorSets, UInt32 descriptors, std::initializer_list<std::initializer_list<DescriptorBinding>> bindings) const = 0;
6551#ifdef __cpp_lib_mdspan
6552 virtual Generator<UniquePtr<IDescriptorSet>> getDescriptorSets(UInt32 descriptorSets, UInt32 descriptors, std::mdspan<DescriptorBinding, std::dextents<size_t, 2>> bindings) const = 0;
6553#endif
6554 virtual Generator<UniquePtr<IDescriptorSet>> getDescriptorSets(UInt32 descriptorSets, UInt32 descriptors, std::function<Generator<DescriptorBinding>(UInt32)> bindingFactory) const = 0;
6555 virtual void releaseDescriptorSet(const IDescriptorSet& descriptorSet) const = 0;
6556 };
6557
6561 class LITEFX_RENDERING_API IPushConstantsRange {
6562 protected:
6563 IPushConstantsRange() noexcept = default;
6566 IPushConstantsRange& operator=(const IPushConstantsRange&) = default;
6567 IPushConstantsRange& operator=(IPushConstantsRange&&) noexcept = default;
6568
6569 public:
6570 virtual ~IPushConstantsRange() noexcept = default;
6571
6572 public:
6577 virtual UInt32 space() const noexcept = 0;
6578
6583 virtual UInt32 binding() const noexcept = 0;
6584
6590 virtual UInt32 offset() const noexcept = 0;
6591
6597 virtual UInt32 size() const noexcept = 0;
6598
6603 virtual ShaderStage stage() const noexcept = 0;
6604 };
6605
6609 class LITEFX_RENDERING_API IPushConstantsLayout {
6610 protected:
6611 IPushConstantsLayout() noexcept = default;
6614 IPushConstantsLayout& operator=(const IPushConstantsLayout&) = default;
6615 IPushConstantsLayout& operator=(IPushConstantsLayout&&) noexcept = default;
6616
6617 public:
6618 virtual ~IPushConstantsLayout() noexcept = default;
6619
6620 public:
6625 virtual UInt32 size() const noexcept = 0;
6626
6635 virtual const IPushConstantsRange& range(ShaderStage stage) const = 0;
6636
6642 inline Enumerable<const IPushConstantsRange&> ranges() const {
6643 return this->getRanges();
6644 }
6645
6646 private:
6647 virtual Enumerable<const IPushConstantsRange&> getRanges() const = 0;
6648 };
6649
6662 struct LITEFX_RENDERING_API IShaderRecord {
6663 public:
6683
6688
6689 protected:
6690 IShaderRecord() noexcept = default;
6691 IShaderRecord(const IShaderRecord&) = default;
6692 IShaderRecord(IShaderRecord&&) noexcept = default;
6693 IShaderRecord& operator=(const IShaderRecord&) = default;
6694 IShaderRecord& operator=(IShaderRecord&&) noexcept = default;
6695
6696 public:
6697 constexpr virtual ~IShaderRecord() noexcept = default;
6698
6699 public:
6704 constexpr ShaderRecordType type() const noexcept {
6705 const auto& group = this->shaderGroup();
6706
6707 if (std::holds_alternative<MeshGeometryHitGroup>(group))
6708 {
6709 return ShaderRecordType::HitGroup;
6710 }
6711 else if (std::holds_alternative<const IShaderModule*>(group))
6712 {
6713 switch (std::get<const IShaderModule*>(group)->type())
6714 {
6715 case ShaderStage::RayGeneration: return ShaderRecordType::RayGeneration;
6716 case ShaderStage::Miss: return ShaderRecordType::Miss;
6717 case ShaderStage::Callable: return ShaderRecordType::Callable;
6718 case ShaderStage::Intersection: return ShaderRecordType::Intersection;
6719 default: return ShaderRecordType::Invalid;
6720 }
6721 }
6722
6723 std::unreachable();
6724 }
6725
6726 public:
6730 constexpr virtual const shader_group_type& shaderGroup() const noexcept = 0;
6731
6742 constexpr virtual const void* localData() const noexcept = 0;
6743
6749 constexpr virtual UInt64 localDataSize() const noexcept = 0;
6750 };
6751
6757 template <typename... TLocalData>
6759
6763 const size_t SHADER_RECORD_LOCAL_DATA_ALIGNMENT { 8 };
6764
6775 template <typename TLocalData> requires
6776 (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT) &&
6777 std::is_standard_layout_v<TLocalData>
6778 struct ShaderRecord<TLocalData> final : public IShaderRecord {
6779 public:
6781
6782 private:
6786 TLocalData m_payload;
6787
6791 shader_group_type m_shaderGroup;
6792
6793 public:
6795 constexpr const shader_group_type& shaderGroup() const noexcept override {
6796 return m_shaderGroup;
6797 }
6798
6800 constexpr const void* localData() const noexcept override {
6801 return static_cast<const void*>(&m_payload);
6802 }
6803
6805 constexpr UInt64 localDataSize() const noexcept override {
6806 return sizeof(TLocalData);
6807 }
6808
6809 public:
6810 ShaderRecord() = delete;
6811
6813 constexpr ~ShaderRecord() noexcept override = default;
6814
6820 ShaderRecord(const shader_group_type& group, TLocalData payload) noexcept :
6821 m_payload(payload), m_shaderGroup(group) { }
6822
6827 constexpr ShaderRecord(const ShaderRecord& _other) = default;
6828
6833 constexpr ShaderRecord(ShaderRecord&& _other) noexcept = default;
6834
6840 constexpr ShaderRecord& operator=(const ShaderRecord& _other) = default;
6841
6847 constexpr ShaderRecord& operator=(ShaderRecord&& _other) noexcept = default;
6848 };
6849
6853 template <>
6854 struct ShaderRecord<> final : public IShaderRecord {
6855 public:
6857
6858 private:
6862 shader_group_type m_shaderGroup;
6863
6864 public:
6866 constexpr const shader_group_type& shaderGroup() const noexcept override {
6867 return m_shaderGroup;
6868 }
6869
6871 constexpr const void* localData() const noexcept override {
6872 return nullptr;
6873 }
6874
6876 constexpr UInt64 localDataSize() const noexcept override {
6877 return 0_ui64;
6878 }
6879
6880 public:
6881 ShaderRecord() = delete;
6882
6884 constexpr ~ShaderRecord() noexcept override = default;
6885
6890 ShaderRecord(const shader_group_type& group) noexcept :
6891 m_shaderGroup(group) { }
6892
6897 constexpr ShaderRecord(const ShaderRecord& _other) = default;
6898
6903 constexpr ShaderRecord(ShaderRecord&& _other) noexcept = default;
6904
6910 constexpr ShaderRecord& operator=(const ShaderRecord& _other) = default;
6911
6917 constexpr ShaderRecord& operator=(ShaderRecord&& _other) noexcept = default;
6918 };
6919
6923 class LITEFX_RENDERING_API ShaderRecordCollection final {
6924 friend class IShaderProgram;
6925
6926 private:
6929
6935 m_program(std::move(shaderProgram))
6936 {
6937 // 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,
6938 // we must validate the program pointer here.
6939 }
6940
6941 public:
6943
6945 ShaderRecordCollection& operator=(ShaderRecordCollection&&) noexcept = default;
6948 ~ShaderRecordCollection() noexcept = default;
6949
6950 private:
6956 const IShaderModule* findShaderModule(StringView name) const noexcept;
6957
6958 public:
6963 inline SharedPtr<const IShaderProgram> program() const noexcept {
6964 return m_program;
6965 }
6966
6971 const Array<UniquePtr<const IShaderRecord>>& shaderRecords() const noexcept;
6972
6979 void addShaderRecord(UniquePtr<const IShaderRecord>&& record);
6980
6981 public:
6991 inline void addShaderRecord(StringView shaderName) {
6992 auto shaderModule = this->findShaderModule(shaderName);
6993
6994 if (shaderModule == nullptr) [[unlikely]]
6995 throw InvalidArgumentException("shaderName", "The parent shader program does not contain a shader named \"{}\".", shaderName);
6996
6997 if (shaderModule->type() == ShaderStage::AnyHit)
6998 this->addShaderRecord(makeUnique<ShaderRecord<>>(IShaderRecord::MeshGeometryHitGroup{ .AnyHitShader = shaderModule }));
6999 else if (shaderModule->type() == ShaderStage::ClosestHit)
7000 this->addShaderRecord(makeUnique<ShaderRecord<>>(IShaderRecord::MeshGeometryHitGroup{ .ClosestHitShader = shaderModule }));
7001 else
7002 this->addShaderRecord(makeUnique<ShaderRecord<>>(shaderModule));
7003 }
7004
7016 template <typename TLocalData> requires (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT)
7017 inline void addShaderRecord(StringView shaderName, TLocalData payload) {
7018 auto shaderModule = this->findShaderModule(shaderName);
7019
7020 if (shaderModule == nullptr) [[unlikely]]
7021 throw InvalidArgumentException("shaderName", "The parent shader program does not contain a shader named \"{}\".", shaderName);
7022
7023 if (shaderModule->type() == ShaderStage::AnyHit)
7024 this->addShaderRecord(makeUnique<ShaderRecord<TLocalData>>(IShaderRecord::MeshGeometryHitGroup{ .AnyHitShader = shaderModule }, payload));
7025 else if (shaderModule->type() == ShaderStage::ClosestHit)
7026 this->addShaderRecord(makeUnique<ShaderRecord<TLocalData>>(IShaderRecord::MeshGeometryHitGroup{ .ClosestHitShader = shaderModule }, payload));
7027 else
7028 this->addShaderRecord(makeUnique<ShaderRecord<TLocalData>>(shaderModule, payload));
7029 }
7030
7037 inline void addMeshGeometryShaderHitGroupRecord(std::optional<StringView> anyHitShaderName, std::optional<StringView> closestHitShaderName) {
7039 .ClosestHitShader = closestHitShaderName.has_value() ? this->findShaderModule(closestHitShaderName.value()) : nullptr,
7040 .AnyHitShader = anyHitShaderName.has_value() ? this->findShaderModule(anyHitShaderName.value()) : nullptr
7041 };
7042
7043 this->addShaderRecord(makeUnique<ShaderRecord<>>(hitGroup));
7044 }
7045
7054 template <typename TLocalData> requires (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT)
7055 inline void addMeshGeometryShaderHitGroupRecord(std::optional<StringView> anyHitShaderName, std::optional<StringView> closestHitShaderName, TLocalData payload) {
7057 .ClosestHitShader = closestHitShaderName.has_value() ? this->findShaderModule(closestHitShaderName.value()) : nullptr,
7058 .AnyHitShader = anyHitShaderName.has_value() ? this->findShaderModule(anyHitShaderName.value()) : nullptr
7059 };
7060
7061 this->addShaderRecord(makeUnique<ShaderRecord<TLocalData>>(hitGroup, payload));
7062 }
7063
7068 inline void addShaderRecord(const ShaderRecord<>::shader_group_type& shaderGroup) {
7069 this->addShaderRecord(makeUnique<ShaderRecord<>>(shaderGroup));
7070 }
7071
7078 template <typename TLocalData> requires (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT)
7079 inline void addShaderRecord(ShaderRecord<TLocalData>::shader_group_type shaderGroup, TLocalData payload) {
7080 this->addShaderRecord(makeUnique<ShaderRecord<TLocalData>>(shaderGroup, payload));
7081 }
7082
7093 this->addShaderRecord(shaderName);
7094 return std::forward<ShaderRecordCollection>(*this);
7095 }
7096
7108 template <typename TLocalData> requires (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT)
7109 inline ShaderRecordCollection&& withShaderRecord(StringView shaderName, TLocalData payload) {
7110 this->addShaderRecord(shaderName, payload);
7111 return std::forward<ShaderRecordCollection>(*this);
7112 }
7113
7120 inline ShaderRecordCollection&& withMeshGeometryHitGroupRecord(std::optional<StringView> anyHitShaderName, std::optional<StringView> closestHitShaderName) {
7121 this->addMeshGeometryShaderHitGroupRecord(anyHitShaderName, closestHitShaderName);
7122 return std::forward<ShaderRecordCollection>(*this);
7123 }
7124
7133 template <typename TLocalData> requires (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT)
7134 inline ShaderRecordCollection&& withMeshGeometryHitGroupRecord(std::optional<StringView> anyHitShaderName, std::optional<StringView> closestHitShaderName, TLocalData payload) {
7135 this->addMeshGeometryShaderHitGroupRecord(anyHitShaderName, closestHitShaderName, payload);
7136 return std::forward<ShaderRecordCollection>(*this);
7137 }
7138
7145 this->addShaderRecord(shaderGroup);
7146 return std::forward<ShaderRecordCollection>(*this);
7147 }
7148
7156 template <typename TLocalData> requires (std::alignment_of_v<TLocalData> == SHADER_RECORD_LOCAL_DATA_ALIGNMENT)
7158 this->addShaderRecord(shaderGroup, payload);
7159 return std::forward<ShaderRecordCollection>(*this);
7160 }
7161 };
7162
7174 struct LITEFX_RENDERING_API PipelineBindingHint {
7175
7184 UInt32 MaxDescriptors{ 0 };
7185 };
7186
7195 bool AsPushConstants{ false };
7196 };
7197
7205 SharedPtr<ISampler> StaticSampler{ nullptr };
7206 };
7207
7224 DescriptorHeapType Type{ DescriptorHeapType::None };
7225
7229 UInt32 HeapSize{ 1u };
7230 };
7231
7248 ShaderStage Stages{ };
7249 };
7250
7255
7260
7264 hint_type Hint = std::monostate{ };
7265
7266 public:
7273 static inline auto runtimeArray(DescriptorBindingPoint at, UInt32 maxDescriptors) noexcept -> PipelineBindingHint {
7274 return { .Binding = at, .Hint = UnboundedArrayHint { maxDescriptors } };
7275 }
7276
7284 static inline auto runtimeArray(UInt32 space, UInt32 binding, UInt32 maxDescriptors) noexcept -> PipelineBindingHint {
7285 return { .Binding = { .Register = binding, .Space = space }, .Hint = UnboundedArrayHint { maxDescriptors } };
7286 }
7287
7293 static inline auto pushConstants(DescriptorBindingPoint at) noexcept -> PipelineBindingHint {
7294 return { .Binding = at, .Hint = PushConstantsHint { true } };
7295 }
7296
7303 static inline auto pushConstants(UInt32 space, UInt32 binding) noexcept -> PipelineBindingHint {
7304 return { .Binding = { .Register = binding, .Space = space }, .Hint = PushConstantsHint { true } };
7305 }
7306
7314 return { .Binding = at, .Hint = StaticSamplerHint { std::move(sampler) } };
7315 }
7316
7324 static inline auto staticSampler(UInt32 space, UInt32 binding, SharedPtr<ISampler> sampler) noexcept -> PipelineBindingHint {
7325 return { .Binding = { .Register = binding, .Space = space }, .Hint = StaticSamplerHint { std::move(sampler) } };
7326 }
7327
7335 static inline auto resourceHeap(DescriptorBindingPoint at, UInt32 heapSize) noexcept -> PipelineBindingHint {
7336 return { .Binding = at, .Hint = DescriptorHeapHint { DescriptorHeapType::Resource, heapSize } };
7337 }
7338
7347 static inline auto resourceHeap(UInt32 space, UInt32 binding, UInt32 heapSize) noexcept -> PipelineBindingHint {
7348 return { .Binding = { .Register = binding, .Space = space }, .Hint = DescriptorHeapHint { DescriptorHeapType::Resource, heapSize } };
7349 }
7350
7358 static inline auto samplerHeap(DescriptorBindingPoint at, UInt32 heapSize) noexcept -> PipelineBindingHint {
7359 return { .Binding = at, .Hint = DescriptorHeapHint { DescriptorHeapType::Sampler, heapSize } };
7360 }
7361
7370 static inline auto samplerHeap(UInt32 space, UInt32 binding, UInt32 heapSize) noexcept -> PipelineBindingHint {
7371 return { .Binding = { .Register = binding, .Space = space }, .Hint = DescriptorHeapHint { DescriptorHeapType::Sampler, heapSize } };
7372 }
7373
7381 static inline auto shaderStage(DescriptorBindingPoint at, ShaderStage shaderStages) noexcept -> PipelineBindingHint {
7382 return { .Binding = at, .Hint = ShaderStageHint { shaderStages } };
7383 }
7384
7393 static inline auto shaderStage(UInt32 space, UInt32 binding, ShaderStage shaderStages) noexcept -> PipelineBindingHint {
7394 return { .Binding = {.Register = binding, .Space = space }, .Hint = ShaderStageHint { shaderStages } };
7395 }
7396 };
7397
7437 class LITEFX_RENDERING_API IShaderProgram : public SharedObject {
7438 protected:
7439 IShaderProgram() noexcept = default;
7440
7441 public:
7442 ~IShaderProgram() noexcept override = default;
7443
7445 IShaderProgram(IShaderProgram&&) noexcept = delete;
7446 auto operator=(const IShaderProgram&) = delete;
7447 auto operator=(IShaderProgram&&) noexcept = delete;
7448
7449 public:
7455 inline const IShaderModule* operator[](StringView name) const {
7456 auto modules = this->getModules();
7457
7458 if (auto match = std::ranges::find_if(modules, [name](auto& module) { return module.fileName().compare(name) == 0; }); match != modules.end())
7459 return std::addressof(*match);
7460
7461 return nullptr;
7462 }
7463
7469 inline bool contains(StringView name) const {
7470 auto modules = this->getModules();
7471 return std::ranges::find_if(modules, [name](const auto& module) { return module.fileName().compare(name) == 0; }) != modules.end();
7472 };
7473
7479 inline bool contains(const IShaderModule& module) const {
7480 auto modules = this->getModules();
7481 return std::ranges::find_if(modules, [&module](const auto& m) { return std::addressof(m) == std::addressof(module); }) != modules.end();
7482 };
7483
7489 return this->getModules();
7490 }
7491
7519 return this->parsePipelineLayout(hints);
7520 };
7521
7526 [[nodiscard]] inline ShaderRecordCollection buildShaderRecordCollection() const noexcept {
7527 return { this->shared_from_this() };
7528 }
7529
7530 private:
7531 virtual Enumerable<const IShaderModule&> getModules() const = 0;
7532 virtual SharedPtr<IPipelineLayout> parsePipelineLayout(Enumerable<PipelineBindingHint> hints) const = 0;
7533 };
7534
7538 class LITEFX_RENDERING_API IPipelineLayout : public SharedObject {
7539 protected:
7540 IPipelineLayout() noexcept = default;
7542 IPipelineLayout(IPipelineLayout&&) noexcept = default;
7543 IPipelineLayout& operator=(const IPipelineLayout&) = default;
7544 IPipelineLayout& operator=(IPipelineLayout&&) noexcept = default;
7545
7546 public:
7547 ~IPipelineLayout() noexcept override = default;
7548
7549 public:
7554 //virtual const IGraphicsDevice& device() const noexcept;
7555
7561 virtual const IDescriptorSetLayout& descriptorSet(UInt32 space) const = 0;
7562
7567 inline Enumerable<SharedPtr<const IDescriptorSetLayout>> descriptorSets() const {
7568 return this->getDescriptorSets();
7569 }
7570
7575 virtual const IPushConstantsLayout* pushConstants() const noexcept = 0;
7576
7581 virtual bool dynamicResourceHeapAccess() const = 0;
7582
7587 virtual bool dynamicSamplerHeapAccess() const = 0;
7588
7589 private:
7590 virtual Enumerable<SharedPtr<const IDescriptorSetLayout>> getDescriptorSets() const = 0;
7591 };
7592
7596 class LITEFX_RENDERING_API IInputAssembler : public SharedObject {
7597 protected:
7598 IInputAssembler() noexcept = default;
7600 IInputAssembler(IInputAssembler&&) noexcept = default;
7601 IInputAssembler& operator=(const IInputAssembler&) = default;
7602 IInputAssembler& operator=(IInputAssembler&&) noexcept = default;
7603
7604 public:
7605 ~IInputAssembler() noexcept override = default;
7606
7607 public:
7612 inline Enumerable<const IVertexBufferLayout&> vertexBufferLayouts() const {
7613 return this->getVertexBufferLayouts();
7614 }
7615
7622 virtual const IVertexBufferLayout& vertexBufferLayout(UInt32 binding) const = 0;
7623
7628 virtual const IIndexBufferLayout* indexBufferLayout() const noexcept = 0;
7629
7634 virtual PrimitiveTopology topology() const noexcept = 0;
7635
7636 private:
7637 virtual Enumerable<const IVertexBufferLayout&> getVertexBufferLayouts() const = 0;
7638 };
7639
7646 class LITEFX_RENDERING_API IPipeline : public virtual IStateResource {
7647 protected:
7648 IPipeline() noexcept = default;
7649 IPipeline(const IPipeline&) = delete;
7650 IPipeline(IPipeline&&) noexcept = default;
7651 IPipeline& operator=(const IPipeline&) = delete;
7652 IPipeline& operator=(IPipeline&&) noexcept = default;
7653
7654 public:
7655 ~IPipeline() noexcept override = default;
7656
7657 public:
7662 inline SharedPtr<const IShaderProgram> program() const noexcept {
7663 return this->getProgram();
7664 }
7665
7671 return this->getLayout();
7672 }
7673
7674 private:
7675 virtual SharedPtr<const IShaderProgram> getProgram() const noexcept = 0;
7676 virtual SharedPtr<const IPipelineLayout> getLayout() const noexcept = 0;
7677 };
7678
7682 class LITEFX_RENDERING_API ICommandBuffer : public SharedObject {
7683 public:
7684 friend class ICommandQueue;
7685
7686 protected:
7687 ICommandBuffer() noexcept = default;
7688 ICommandBuffer(ICommandBuffer&&) noexcept = default;
7690 ICommandBuffer& operator=(const ICommandBuffer&) = default;
7691 ICommandBuffer& operator=(ICommandBuffer&&) noexcept = default;
7692
7693 public:
7694 ~ICommandBuffer() noexcept override = default;
7695
7696 public:
7705 virtual void begin() const = 0;
7706
7714 virtual void end() const = 0;
7715
7720 virtual bool isSecondary() const noexcept = 0;
7721
7739 virtual void track(SharedPtr<const IBuffer> buffer) const = 0;
7740
7747 virtual void track(SharedPtr<const IImage> image) const = 0;
7748
7755 virtual void track(SharedPtr<const ISampler> sampler) const = 0;
7756
7761 virtual void track(UniquePtr<const IDescriptorSet>&& descriptorSet) const = 0;
7762
7763 public:
7768 inline SharedPtr<const ICommandQueue> queue() const noexcept {
7769 return this->getQueue();
7770 }
7771
7778 [[nodiscard]] inline UniquePtr<IBarrier> makeBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const {
7779 return this->getBarrier(syncBefore, syncAfter);
7780 }
7781
7791 inline void barrier(const IBarrier& barrier) const noexcept {
7792 this->cmdBarrier(barrier);
7793 }
7794
7809 inline void transfer(const IBuffer& source, const IBuffer& target, UInt32 sourceElement = 0, UInt32 targetElement = 0, UInt32 elements = 1) const {
7810 this->cmdTransfer(source, target, sourceElement, targetElement, elements);
7811 }
7812
7833 inline void transfer(const SharedPtr<const IBuffer>& source, const IBuffer& target, UInt32 sourceElement = 0, UInt32 targetElement = 0, UInt32 elements = 1) const {
7834 this->cmdTransfer(source, target, sourceElement, targetElement, elements);
7835 }
7836
7850 inline void transfer(const void* const data, size_t size, const IBuffer& target, UInt32 targetElement = 0, UInt32 elements = 1) const {
7851 this->cmdTransfer(data, size, target, targetElement, elements);
7852 }
7853
7866 inline void transfer(Span<const void* const> data, size_t elementSize, const IBuffer& target, UInt32 targetElement = 0) const {
7867 this->cmdTransfer(data, elementSize, target, targetElement);
7868 }
7869
7905 inline void transfer(const IBuffer& source, const IImage& target, UInt32 sourceElement = 0, UInt32 firstSubresource = 0, UInt32 elements = 1) const {
7906 this->cmdTransfer(source, target, sourceElement, firstSubresource, elements);
7907 }
7908
7951 inline void transfer(const SharedPtr<const IBuffer>& source, const IImage& target, UInt32 sourceElement = 0, UInt32 firstSubresource = 0, UInt32 elements = 1) const {
7952 this->cmdTransfer(source, target, sourceElement, firstSubresource, elements);
7953 }
7954
7968 inline void transfer(const void* const data, size_t size, const IImage& target, UInt32 subresource = 0) const {
7969 this->cmdTransfer(data, size, target, subresource);
7970 }
7971
7985 inline void transfer(Span<const void* const> data, size_t elementSize, const IImage& target, UInt32 firstSubresource = 0, UInt32 elements = 1) const {
7986 this->cmdTransfer(data, elementSize, target, firstSubresource, elements);
7987 }
7988
8002 inline void transfer(const IImage& source, const IImage& target, UInt32 sourceSubresource = 0, UInt32 targetSubresource = 0, UInt32 subresources = 1) const {
8003 this->cmdTransfer(source, target, sourceSubresource, targetSubresource, subresources);
8004 }
8005
8026 inline void transfer(const SharedPtr<const IImage>& source, const IImage& target, UInt32 sourceSubresource = 0, UInt32 targetSubresource = 0, UInt32 subresources = 1) const {
8027 this->cmdTransfer(source, target, sourceSubresource, targetSubresource, subresources);
8028 }
8029
8065 inline void transfer(const IImage& source, const IBuffer& target, UInt32 firstSubresource = 0, UInt32 targetElement = 0, UInt32 subresources = 1) const {
8066 this->cmdTransfer(source, target, firstSubresource, targetElement, subresources);
8067 }
8068
8111 inline void transfer(const SharedPtr<const IImage>& source, const IBuffer& target, UInt32 firstSubresource = 0, UInt32 targetElement = 0, UInt32 subresources = 1) const {
8112 this->cmdTransfer(source, target, firstSubresource, targetElement, subresources);
8113 }
8114
8118 inline void use(const IPipeline& pipeline) const noexcept {
8119 this->cmdUse(pipeline);
8120 }
8121
8128 inline void bind(const IDescriptorSet& descriptorSet) const {
8129 this->cmdBind(descriptorSet);
8130 }
8131
8141 template <typename TSelf, typename T>
8142 inline void bind(this const TSelf& self, std::initializer_list<const T*> descriptorSets) requires
8143 std::derived_from<T, IDescriptorSet>
8144 {
8145 // NOTE: In the future we might be able to remove this method, if P2447R4 is added to the language.
8146 Array<const T*> sets = descriptorSets;
8147 self.bind(Span<const T*>(sets));
8148 }
8149
8158 template <typename TSelf>
8159 inline void bind(this const TSelf& self, std::ranges::input_range auto&& descriptorSets) requires
8160 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>
8161 {
8162 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)>>>>>>;
8163 auto sets = descriptorSets | std::ranges::to<Array<const descriptor_set_type*>>();
8164 self.bind(Span<const descriptor_set_type*>(sets));
8165 }
8166
8174 inline void bind(Span<const IDescriptorSet*> descriptorSets) const {
8175 this->cmdBind(descriptorSets);
8176 }
8177
8183 inline void bind(const IDescriptorSet& descriptorSet, const IPipeline& pipeline) const {
8184 this->cmdBind(descriptorSet, pipeline);
8185 }
8186
8197 template <typename TSelf, typename T>
8198 inline void bind(this const TSelf& self, std::initializer_list<const T*> descriptorSets, const typename TSelf::pipeline_type& pipeline)
8199 {
8200 // NOTE: In the future we might be able to remove this method, if P2447R4 is added to the language.
8201 Array<const T*> sets = descriptorSets;
8202 self.bind(Span<const T*>(sets), pipeline);
8203 }
8204
8213 template <typename TSelf>
8214 inline void bind(this const TSelf& self, std::ranges::input_range auto&& descriptorSets, const typename TSelf::pipeline_type& pipeline) requires
8215 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>
8216 {
8217 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)>>>>>>;
8218 auto sets = descriptorSets | std::ranges::to<Array<const descriptor_set_type*>>();
8219 self.bind(Span<const descriptor_set_type*>(sets), pipeline);
8220 }
8221
8230 inline void bind(Span<const IDescriptorSet*> descriptorSets, const IPipeline& pipeline) const {
8231 this->cmdBind(descriptorSets, pipeline);
8232 }
8233
8244 inline void bind(const IVertexBuffer& buffer) const {
8245 this->cmdBind(buffer);
8246 }
8247
8257 inline void bind(const IIndexBuffer& buffer) const {
8258 this->cmdBind(buffer);
8259 }
8260
8266 virtual void dispatch(const Vector3u& threadGroupCount) const noexcept = 0;
8267
8274 inline void dispatch(UInt32 x, UInt32 y, UInt32 z) const noexcept {
8275 this->dispatch({ x, y, z });
8276 }
8277
8285 inline void dispatchIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset = 0) const noexcept {
8286 this->cmdDispatchIndirect(batchBuffer, batchCount, offset);
8287 }
8288
8296 virtual void dispatchMesh(const Vector3u& threadGroupCount) const noexcept = 0;
8297
8307 inline void dispatchMesh(UInt32 x, UInt32 y, UInt32 z) const noexcept {
8308 this->dispatchMesh({ x, y, z });
8309 }
8310
8318 inline void dispatchMeshIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset = 0) const noexcept {
8319 this->cmdDispatchMeshIndirect(batchBuffer, batchCount, offset);
8320 }
8321
8331 inline void dispatchMeshIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset = 0, UInt64 countOffset = 0, UInt32 maxBatches = std::numeric_limits<UInt32>::max()) const noexcept {
8332 this->cmdDispatchMeshIndirect(batchBuffer, countBuffer, offset, countOffset, maxBatches);
8333 }
8334
8349 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 {
8350 this->cmdTraceRays(width, height, depth, offsets, rayGenerationShaderBindingTable, missShaderBindingTable, hitShaderBindingTable, callableShaderBindingTable);
8351 }
8352
8365 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 {
8366 this->traceRays(dimensions.x(), dimensions.y(), dimensions.z(), offsets, rayGenerationShaderBindingTable, missShaderBindingTable, hitShaderBindingTable, callableShaderBindingTable);
8367 }
8368
8377 virtual void draw(UInt32 vertices, UInt32 instances = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) const noexcept = 0;
8378
8389 inline void draw(const IVertexBuffer& vertexBuffer, UInt32 instances = 1, UInt32 firstVertex = 0, UInt32 firstInstance = 0) const {
8390 this->cmdDraw(vertexBuffer, instances, firstVertex, firstInstance);
8391 }
8392
8400 inline void drawIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset = 0) const noexcept {
8401 this->cmdDrawIndirect(batchBuffer, batchCount, offset);
8402 }
8403
8413 inline void drawIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset = 0, UInt64 countOffset = 0, UInt32 maxBatches = std::numeric_limits<UInt32>::max()) const noexcept {
8414 this->cmdDrawIndirect(batchBuffer, countBuffer, offset, countOffset, maxBatches);
8415 }
8416
8426 virtual void drawIndexed(UInt32 indices, UInt32 instances = 1, UInt32 firstIndex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0) const noexcept = 0;
8427
8439 inline void drawIndexed(const IIndexBuffer& indexBuffer, UInt32 instances = 1, UInt32 firstIndex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0) const {
8440 this->cmdDrawIndexed(indexBuffer, instances, firstIndex, vertexOffset, firstInstance);
8441 }
8442
8455 inline void drawIndexed(const IVertexBuffer& vertexBuffer, const IIndexBuffer& indexBuffer, UInt32 instances = 1, UInt32 firstIndex = 0, Int32 vertexOffset = 0, UInt32 firstInstance = 0) const {
8456 this->cmdDrawIndexed(vertexBuffer, indexBuffer, instances, firstIndex, vertexOffset, firstInstance);
8457 }
8458
8466 inline void drawIndexedIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset = 0) const noexcept {
8467 this->cmdDrawIndexedIndirect(batchBuffer, batchCount, offset);
8468 }
8469
8479 inline void drawIndexedIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset = 0, UInt64 countOffset = 0, UInt32 maxBatches = std::numeric_limits<UInt32>::max()) const noexcept {
8480 this->cmdDrawIndexedIndirect(batchBuffer, countBuffer, offset, countOffset, maxBatches);
8481 }
8482
8488 inline void pushConstants(const IPushConstantsLayout& layout, const void* const memory) const {
8489 this->cmdPushConstants(layout, memory);
8490 }
8491
8496 virtual void setViewports(Span<const IViewport*> viewports) const = 0;
8497
8502 virtual void setViewports(const IViewport* viewport) const = 0;
8503
8508 virtual void setScissors(Span<const IScissor*> scissors) const = 0;
8509
8514 virtual void setScissors(const IScissor* scissor) const = 0;
8515
8524 virtual void setBlendFactors(const Vector4f& blendFactors) const noexcept = 0;
8525
8530 virtual void setStencilRef(UInt32 stencilRef) const noexcept = 0;
8531
8543 virtual void setDepthBounds(Float minBounds, Float maxBounds) const noexcept = 0;
8544
8549 virtual UInt64 submit() const = 0;
8550
8555 virtual void writeTimingEvent(const SharedPtr<const TimingEvent>& timingEvent) const = 0;
8556
8561 inline void execute(const SharedPtr<const ICommandBuffer>& commandBuffer) const {
8562 this->cmdExecute(commandBuffer);
8563 }
8564
8569 inline void execute(Enumerable<SharedPtr<const ICommandBuffer>> commandBuffers) const {
8570 this->cmdExecute(std::move(commandBuffers));
8571 }
8572
8585 inline void buildAccelerationStructure(IBottomLevelAccelerationStructure& blas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset = 0) const {
8586 this->cmdBuildAccelerationStructure(blas, scratchBuffer, buffer, offset);
8587 }
8588
8601 inline void buildAccelerationStructure(ITopLevelAccelerationStructure& tlas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset = 0) const {
8602 this->cmdBuildAccelerationStructure(tlas, scratchBuffer, buffer, offset);
8603 }
8604
8617 inline void updateAccelerationStructure(IBottomLevelAccelerationStructure& blas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset = 0) const {
8618 this->cmdUpdateAccelerationStructure(blas, scratchBuffer, buffer, offset);
8619 }
8620
8633 inline void updateAccelerationStructure(ITopLevelAccelerationStructure& tlas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset = 0) const {
8634 this->cmdUpdateAccelerationStructure(tlas, scratchBuffer, buffer, offset);
8635 }
8636
8650 inline void copyAccelerationStructure(const IBottomLevelAccelerationStructure& from, const IBottomLevelAccelerationStructure& to, bool compress = false) const noexcept {
8651 this->cmdCopyAccelerationStructure(from, to, compress);
8652 }
8653
8667 inline void copyAccelerationStructure(const ITopLevelAccelerationStructure& from, const ITopLevelAccelerationStructure& to, bool compress = false) const noexcept {
8668 this->cmdCopyAccelerationStructure(from, to, compress);
8669 }
8670
8671 protected:
8675 virtual void releaseSharedState() const = 0;
8676
8677 private:
8678 virtual SharedPtr<const ICommandQueue> getQueue() const noexcept = 0;
8679 virtual UniquePtr<IBarrier> getBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const = 0;
8680 virtual void cmdBarrier(const IBarrier& barrier) const noexcept = 0;
8681 virtual void cmdTransfer(const IBuffer& source, const IBuffer& target, UInt32 sourceElement, UInt32 targetElement, UInt32 elements) const = 0;
8682 virtual void cmdTransfer(const IBuffer& source, const IImage& target, UInt32 sourceElement, UInt32 firstSubresource, UInt32 elements) const = 0;
8683 virtual void cmdTransfer(const IImage& source, const IImage& target, UInt32 sourceSubresource, UInt32 targetSubresource, UInt32 subresources) const = 0;
8684 virtual void cmdTransfer(const IImage& source, const IBuffer& target, UInt32 firstSubresource, UInt32 targetElement, UInt32 subresources) const = 0;
8685 virtual void cmdTransfer(const SharedPtr<const IBuffer>& source, const IBuffer& target, UInt32 sourceElement, UInt32 targetElement, UInt32 elements) const = 0;
8686 virtual void cmdTransfer(const SharedPtr<const IBuffer>& source, const IImage& target, UInt32 sourceElement, UInt32 firstSubresource, UInt32 elements) const = 0;
8687 virtual void cmdTransfer(const SharedPtr<const IImage>& source, const IImage& target, UInt32 sourceSubresource, UInt32 targetSubresource, UInt32 subresources) const = 0;
8688 virtual void cmdTransfer(const SharedPtr<const IImage>& source, const IBuffer& target, UInt32 firstSubresource, UInt32 targetElement, UInt32 subresources) const = 0;
8689 virtual void cmdTransfer(const void* const data, size_t size, const IBuffer& target, UInt32 targetElement, UInt32 elements) const = 0;
8690 virtual void cmdTransfer(Span<const void* const> data, size_t elementSize, const IBuffer& target, UInt32 targetElement) const = 0;
8691 virtual void cmdTransfer(const void* const data, size_t size, const IImage& target, UInt32 subresource) const = 0;
8692 virtual void cmdTransfer(Span<const void* const> data, size_t elementSize, const IImage& target, UInt32 firstSubresource, UInt32 elements) const = 0;
8693 virtual void cmdUse(const IPipeline& pipeline) const noexcept = 0;
8694 virtual void cmdBind(const IDescriptorSet& descriptorSet) const = 0;
8695 virtual void cmdBind(Span<const IDescriptorSet*> descriptorSets) const = 0;
8696 virtual void cmdBind(const IDescriptorSet& descriptorSet, const IPipeline& pipeline) const = 0;
8697 virtual void cmdBind(Span<const IDescriptorSet*> descriptorSets, const IPipeline& pipeline) const = 0;
8698 virtual void cmdBind(const IVertexBuffer& buffer) const = 0;
8699 virtual void cmdBind(const IIndexBuffer& buffer) const = 0;
8700 virtual void cmdPushConstants(const IPushConstantsLayout& layout, const void* const memory) const = 0;
8701 virtual void cmdDispatchIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset) const noexcept = 0;
8702 virtual void cmdDispatchMeshIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset) const noexcept = 0;
8703 virtual void cmdDispatchMeshIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset, UInt64 countOffset, UInt32 maxBatches) const noexcept = 0;
8704 virtual void cmdDraw(const IVertexBuffer& vertexBuffer, UInt32 instances, UInt32 firstVertex, UInt32 firstInstance) const = 0;
8705 virtual void cmdDrawIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset) const noexcept = 0;
8706 virtual void cmdDrawIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset, UInt64 countOffset, UInt32 maxBatches) const noexcept = 0;
8707 virtual void cmdDrawIndexed(const IIndexBuffer& indexBuffer, UInt32 instances, UInt32 firstIndex, Int32 vertexOffset, UInt32 firstInstance) const = 0;
8708 virtual void cmdDrawIndexed(const IVertexBuffer& vertexBuffer, const IIndexBuffer& indexBuffer, UInt32 instances, UInt32 firstIndex, Int32 vertexOffset, UInt32 firstInstance) const = 0;
8709 virtual void cmdDrawIndexedIndirect(const IBuffer& batchBuffer, UInt32 batchCount, UInt64 offset) const noexcept = 0;
8710 virtual void cmdDrawIndexedIndirect(const IBuffer& batchBuffer, const IBuffer& countBuffer, UInt64 offset, UInt64 countOffset, UInt32 maxBatches) const noexcept = 0;
8711 virtual void cmdExecute(const SharedPtr<const ICommandBuffer>& commandBuffer) const = 0;
8712 virtual void cmdExecute(Enumerable<SharedPtr<const ICommandBuffer>> commandBuffer) const = 0;
8713 virtual void cmdBuildAccelerationStructure(IBottomLevelAccelerationStructure& blas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset) const = 0;
8714 virtual void cmdBuildAccelerationStructure(ITopLevelAccelerationStructure& tlas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset) const = 0;
8715 virtual void cmdUpdateAccelerationStructure(IBottomLevelAccelerationStructure& blas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset) const = 0;
8716 virtual void cmdUpdateAccelerationStructure(ITopLevelAccelerationStructure& tlas, const SharedPtr<const IBuffer>& scratchBuffer, const IBuffer& buffer, UInt64 offset) const = 0;
8717 virtual void cmdCopyAccelerationStructure(const IBottomLevelAccelerationStructure& from, const IBottomLevelAccelerationStructure& to, bool compress) const noexcept = 0;
8718 virtual void cmdCopyAccelerationStructure(const ITopLevelAccelerationStructure& from, const ITopLevelAccelerationStructure& to, bool compress) const noexcept = 0;
8719 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;
8720 };
8721
8725 class LITEFX_RENDERING_API IRenderPipeline : public virtual IPipeline {
8726 protected:
8727 IRenderPipeline() noexcept = default;
8728 IRenderPipeline(IRenderPipeline&&) noexcept = default;
8730 IRenderPipeline& operator=(IRenderPipeline&&) noexcept = default;
8731 IRenderPipeline& operator=(const IRenderPipeline&) = delete;
8732
8733 public:
8734 ~IRenderPipeline() noexcept override = default;
8735
8736 public:
8741 inline SharedPtr<IInputAssembler> inputAssembler() const noexcept {
8742 return this->getInputAssembler();
8743 }
8744
8749 inline SharedPtr<IRasterizer> rasterizer() const noexcept {
8750 return this->getRasterizer();
8751 }
8752
8766 virtual bool alphaToCoverage() const noexcept = 0;
8767
8776 virtual MultiSamplingLevel samples() const noexcept = 0;
8777
8785 virtual void updateSamples(MultiSamplingLevel samples) = 0;
8786
8787 private:
8788 virtual SharedPtr<IInputAssembler> getInputAssembler() const noexcept = 0;
8789 virtual SharedPtr<IRasterizer> getRasterizer() const noexcept = 0;
8790 };
8791
8795 class LITEFX_RENDERING_API IComputePipeline : public virtual IPipeline {
8796 protected:
8797 IComputePipeline() noexcept = default;
8798 IComputePipeline(IComputePipeline&&) noexcept = default;
8800 IComputePipeline& operator=(IComputePipeline&&) noexcept = default;
8801 IComputePipeline& operator=(const IComputePipeline&) = delete;
8802
8803 public:
8804 ~IComputePipeline() noexcept override = default;
8805 };
8806
8810 class LITEFX_RENDERING_API IRayTracingPipeline : public virtual IPipeline {
8811 protected:
8812 IRayTracingPipeline() noexcept = default;
8815 IRayTracingPipeline& operator=(IRayTracingPipeline&&) noexcept = default;
8816 IRayTracingPipeline& operator=(const IRayTracingPipeline&) = delete;
8817
8818 public:
8819 ~IRayTracingPipeline() noexcept override = default;
8820
8821 public:
8826 virtual const ShaderRecordCollection& shaderRecords() const noexcept = 0;
8827
8832 virtual UInt32 maxRecursionDepth() const noexcept = 0;
8833
8845 virtual UInt32 maxPayloadSize() const noexcept = 0;
8846
8856 virtual UInt32 maxAttributeSize() const noexcept = 0;
8857
8873 inline SharedPtr<IBuffer> allocateShaderBindingTable(ShaderBindingTableOffsets& offsets, ShaderBindingGroup groups = ShaderBindingGroup::All) const {
8874 return this->getShaderBindingTable(offsets, groups);
8875 }
8876
8877 private:
8878 virtual SharedPtr<IBuffer> getShaderBindingTable(ShaderBindingTableOffsets& offsets, ShaderBindingGroup groups) const = 0;
8879 };
8880
8903 class LITEFX_RENDERING_API IFrameBuffer : public virtual IStateResource, public SharedObject {
8904 public:
8924 template <typename TImage>
8925 using allocation_callback_type = std::function<SharedPtr<const TImage>(Optional<UInt64>, Size2d, ResourceUsage, Format, MultiSamplingLevel, const String&)>;
8926
8927 public:
8933 struct ResizeEventArgs : public EventArgs {
8934 private:
8935 Size2d m_newSize;
8936
8937 public:
8938 ResizeEventArgs(Size2d newSize) noexcept :
8939 EventArgs(), m_newSize(std::move(newSize)) { }
8941 ResizeEventArgs(ResizeEventArgs&&) noexcept = default;
8942 ResizeEventArgs& operator=(const ResizeEventArgs&) = default;
8943 ResizeEventArgs& operator=(ResizeEventArgs&&) noexcept = default;
8944 ~ResizeEventArgs() noexcept override = default;
8945
8946 public:
8951 inline const Size2d& newSize() const noexcept {
8952 return m_newSize;
8953 }
8954 };
8955
8962 public:
8964 EventArgs() { }
8967 ReleasedEventArgs& operator=(const ReleasedEventArgs&) = default;
8968 ReleasedEventArgs& operator=(ReleasedEventArgs&&) noexcept = default;
8969 ~ReleasedEventArgs() noexcept override = default;
8970 };
8971
8972 protected:
8973 IFrameBuffer() noexcept = default;
8974 IFrameBuffer(IFrameBuffer&&) noexcept = default;
8975 IFrameBuffer(const IFrameBuffer&) = delete;
8976 IFrameBuffer& operator=(IFrameBuffer&&) noexcept = default;
8977 IFrameBuffer& operator=(const IFrameBuffer&) = delete;
8978
8979 public:
8983 inline ~IFrameBuffer() noexcept override {
8984 released.invoke(this, { });
8985 }
8986
8987 public:
8994
9001
9012
9013 public:
9021 virtual const Size2d& size() const noexcept = 0;
9022
9030 virtual size_t getWidth() const noexcept = 0;
9031
9039 virtual size_t getHeight() const noexcept = 0;
9040
9054 virtual void mapRenderTarget(const RenderTarget& renderTarget, UInt32 index) = 0;
9055
9069 virtual void mapRenderTarget(const RenderTarget& renderTarget, StringView imageName) = 0;
9070
9083 inline void mapRenderTarget(const RenderTarget& renderTarget) {
9084 this->mapRenderTarget(renderTarget, renderTarget.name());
9085 }
9086
9094 inline void mapRenderTargets(Span<const RenderTarget> renderTargets) {
9095 std::ranges::for_each(renderTargets, [this](auto& renderTarget) { this->mapRenderTarget(renderTarget); });
9096 }
9097
9106 virtual void unmapRenderTarget(const RenderTarget& renderTarget) noexcept = 0;
9107
9113 return this->getImages();
9114 }
9115
9122 virtual const IImage& operator[](UInt32 index) const = 0;
9123
9130 virtual const IImage& image(UInt32 index) const = 0;
9131
9138 virtual const IImage& operator[](const RenderTarget& renderTarget) const = 0;
9139
9146 virtual const IImage& image(const RenderTarget& renderTarget) const = 0;
9147
9154 virtual const IImage& operator[](StringView renderTargetName) const = 0;
9155
9162 virtual const IImage& image(StringView renderTargetName) const = 0;
9163
9171 virtual const IImage& resolveImage(UInt64 hash) const = 0;
9172
9179 template <typename TSelf>
9180 inline auto addImage(this TSelf&& self, Format format, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) -> TSelf&& {
9181 self.addImage(format, samples, usage);
9182 return std::forward<TSelf>(self);
9183 }
9184
9191 inline void addImage(Format format, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) {
9192 this->addImage("", format, samples, usage);
9193 }
9194
9202 template <typename TSelf>
9203 inline auto addImage(this TSelf&& self, StringView name, Format format, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) -> TSelf&& {
9204 self.addImage(name, format, samples, usage);
9205 return std::forward<TSelf>(self);
9206 }
9207
9216 virtual void addImage(const String& name, Format format, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) = 0;
9217
9224 template <typename TSelf>
9225 inline auto addImage(this TSelf&& self, const RenderTarget& renderTarget, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) -> TSelf&& {
9226 self.addImage(renderTarget, samples, usage);
9227 return std::forward<TSelf>(self);
9228 }
9229
9236 inline void addImage(const RenderTarget& renderTarget, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) {
9237 this->addImage(renderTarget.name(), renderTarget, samples, usage);
9238 }
9239
9247 template <typename TSelf>
9248 inline auto addImage(this TSelf&& self, StringView name, const RenderTarget& renderTarget, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) -> TSelf&& {
9249 self.addImage(name, renderTarget, samples, usage);
9250 return std::forward<TSelf>(self);
9251 }
9252
9260 virtual void addImage(const String& name, const RenderTarget& renderTarget, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) = 0;
9261
9271 template <typename TSelf>
9272 inline auto addImages(this TSelf&& self, Span<const RenderTarget> renderTargets, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::FrameBufferImage) -> TSelf&& {
9273 std::ranges::for_each(renderTargets, [&](auto& renderTarget) { self.addImage(renderTarget.name(), renderTarget, samples, usage); });
9274 return std::forward<TSelf>(self);
9275 }
9276
9283 virtual void resize(const Size2d& renderArea) = 0;
9284
9285 private:
9286 virtual Enumerable<const IImage&> getImages() const = 0;
9287 };
9288
9292 class LITEFX_RENDERING_API IRenderPass : public virtual IStateResource, public SharedObject {
9293 public:
9298 struct BeginEventArgs : public EventArgs {
9299 private:
9300 const IFrameBuffer* m_frameBuffer;
9301
9302 public:
9303 BeginEventArgs(const IFrameBuffer& frameBuffer) noexcept :
9304 EventArgs(), m_frameBuffer(&frameBuffer) { }
9306 BeginEventArgs(BeginEventArgs&&) noexcept = default;
9307 BeginEventArgs& operator=(const BeginEventArgs&) = default;
9308 BeginEventArgs& operator=(BeginEventArgs&&) noexcept = default;
9309 ~BeginEventArgs() noexcept override = default;
9310
9311 public:
9316 inline const IFrameBuffer& frameBuffer() const noexcept {
9317 return *m_frameBuffer;
9318 }
9319 };
9320
9321 protected:
9322 IRenderPass() noexcept = default;
9323 IRenderPass(IRenderPass&&) noexcept = default;
9324 IRenderPass(const IRenderPass&) = delete;
9325 IRenderPass& operator=(IRenderPass&&) noexcept = default;
9326 IRenderPass& operator=(const IRenderPass&) = delete;
9327
9328 public:
9329 ~IRenderPass() noexcept override = default;
9330
9331 public:
9336 mutable Event<BeginEventArgs> beginning;
9337
9342 mutable Event<EventArgs> ending;
9343
9344 public:
9349 //virtual const IGraphicsDevice& device() const noexcept;
9350
9361 inline SharedPtr<const IFrameBuffer> activeFrameBuffer() const noexcept {
9362 return this->getActiveFrameBuffer();
9363 }
9364
9369 inline const ICommandQueue& commandQueue() const noexcept {
9370 return this->getCommandQueue();
9371 }
9372
9382 return this->getCommandBuffers();
9383 }
9384
9394 return this->getCommandBuffer(index);
9395 }
9396
9401 virtual UInt32 secondaryCommandBuffers() const noexcept = 0;
9402
9411 virtual const Array<RenderTarget>& renderTargets() const noexcept = 0;
9412
9418 virtual const RenderTarget& renderTarget(UInt32 location) const = 0;
9419
9425 virtual bool hasPresentTarget() const noexcept = 0;
9426
9431 virtual const Array<RenderPassDependency>& inputAttachments() const noexcept = 0;
9432
9438 virtual const RenderPassDependency& inputAttachment(UInt32 location) const = 0;
9439
9447 virtual const Optional<DescriptorBindingPoint>& inputAttachmentSamplerBinding() const noexcept = 0;
9448
9453 inline void begin(const IFrameBuffer& frameBuffer) const {
9454 this->beginRenderPass(frameBuffer);
9455 };
9456
9464 virtual UInt64 end() const = 0;
9465
9471 virtual UInt32 viewMask() const noexcept = 0;
9472
9473 private:
9474 virtual SharedPtr<const IFrameBuffer> getActiveFrameBuffer() const noexcept = 0;
9475 virtual void beginRenderPass(const IFrameBuffer& frameBuffer) const = 0;
9476 virtual const ICommandQueue& getCommandQueue() const noexcept = 0;
9477 virtual SharedPtr<const ICommandBuffer> getCommandBuffer(UInt32 index) const noexcept = 0;
9478 virtual Enumerable<SharedPtr<const ICommandBuffer>> getCommandBuffers() const = 0;
9479 };
9480
9484 class LITEFX_RENDERING_API ISwapChain {
9485 public:
9489 struct ResetEventArgs : public EventArgs {
9490 private:
9491 Format m_surfaceFormat;
9492 Size2d m_renderArea;
9493 UInt32 m_buffers;
9494 bool m_vsync;
9495
9496 public:
9497 ResetEventArgs(Format surfaceFormat, Size2d renderArea, UInt32 buffers, bool enableVsync) noexcept :
9498 EventArgs(), m_surfaceFormat(surfaceFormat), m_renderArea(std::move(renderArea)), m_buffers(buffers), m_vsync(enableVsync) { }
9500 ResetEventArgs(ResetEventArgs&&) noexcept = default;
9501 ResetEventArgs& operator=(const ResetEventArgs&) = default;
9502 ResetEventArgs& operator=(ResetEventArgs&&) noexcept = default;
9503 ~ResetEventArgs() noexcept override = default;
9504
9505 public:
9510 inline Format surfaceFormat() const noexcept {
9511 return m_surfaceFormat;
9512 }
9513
9518 inline const Size2d& renderArea() const noexcept {
9519 return m_renderArea;
9520 }
9521
9526 inline UInt32 buffers() const noexcept {
9527 return m_buffers;
9528 }
9529
9534 inline bool enableVsync() const noexcept {
9535 return m_vsync;
9536 }
9537 };
9538
9543 private:
9544 UInt32 m_backBuffer;
9545
9546 public:
9547 explicit BackBufferSwapEventArgs(UInt32 backBuffer) noexcept :
9548 EventArgs(), m_backBuffer(backBuffer) {
9549 }
9553 BackBufferSwapEventArgs& operator=(BackBufferSwapEventArgs&&) noexcept = default;
9554 ~BackBufferSwapEventArgs() noexcept override = default;
9555
9556 public:
9561 UInt32 backBuffer() const noexcept {
9562 return m_backBuffer;
9563 }
9564 };
9565
9566 protected:
9567 ISwapChain() noexcept = default;
9568 ISwapChain(ISwapChain&&) noexcept = default;
9569 ISwapChain(const ISwapChain&) = default;
9570 ISwapChain& operator=(const ISwapChain&) = default;
9571 ISwapChain& operator=(ISwapChain&&) noexcept = default;
9572
9573 public:
9574 virtual ~ISwapChain() noexcept = default;
9575
9576 public:
9586 [[nodiscard]] inline SharedPtr<const TimingEvent> registerTimingEvent(StringView name = "") {
9587 auto timingEvent = TimingEvent::create(*this, name);
9588 this->addTimingEvent(timingEvent);
9589 return timingEvent;
9590 }
9591
9597
9604
9616
9624
9630 virtual const IGraphicsDevice& device() const = 0;
9631
9632 public:
9637 virtual Format surfaceFormat() const noexcept = 0;
9638
9643 virtual UInt32 buffers() const noexcept = 0;
9644
9649 virtual const Size2d& renderArea() const noexcept = 0;
9650
9655 virtual bool verticalSynchronization() const noexcept = 0;
9656
9662 virtual IImage* image(UInt32 backBuffer) const = 0;
9663
9668 virtual const IImage& image() const noexcept = 0;
9669
9674 inline Enumerable<IImage&> images() const {
9675 return this->getImages();
9676 };
9677
9688 virtual void present(UInt64 fence) const = 0;
9689
9690 public:
9696
9702
9710
9726 virtual void reset(Format surfaceFormat, const Size2d& renderArea, UInt32 buffers, bool enableVsync = false) = 0;
9727
9732 [[nodiscard]] virtual UInt32 swapBackBuffer() const = 0;
9733
9734 private:
9735 virtual Enumerable<IImage&> getImages() const = 0;
9736 virtual void addTimingEvent(SharedPtr<const TimingEvent> timingEvent) = 0;
9737 };
9738
9742 class LITEFX_RENDERING_API ICommandQueue : public SharedObject {
9743 public:
9748 private:
9749 Array<SharedPtr<const ICommandBuffer>> m_commandBuffers;
9750
9751 public:
9753 EventArgs(), m_commandBuffers(std::move(commandBuffers)) { }
9754
9758 QueueSubmittingEventArgs& operator=(QueueSubmittingEventArgs&&) noexcept = default;
9759 ~QueueSubmittingEventArgs() noexcept override = default;
9760
9761 public:
9766 inline const Array<SharedPtr<const ICommandBuffer>>& commandBuffers() const noexcept {
9767 return m_commandBuffers;
9768 }
9769 };
9770
9775 private:
9776 UInt64 m_fence;
9777
9778 public:
9780 EventArgs(), m_fence(fence) { }
9784 QueueSubmittedEventArgs& operator=(QueueSubmittedEventArgs&&) noexcept = default;
9785 ~QueueSubmittedEventArgs() noexcept override = default;
9786
9787 public:
9792 inline UInt64 fence() const noexcept {
9793 return m_fence;
9794 }
9795 };
9796
9797 protected:
9798 ICommandQueue() noexcept = default;
9799 ICommandQueue(const ICommandQueue&) = default;
9800 ICommandQueue(ICommandQueue&&) noexcept = default;
9801 ICommandQueue& operator=(const ICommandQueue&) = default;
9802 ICommandQueue& operator=(ICommandQueue&&) noexcept = default;
9803
9804 public:
9805 ~ICommandQueue() noexcept override = default;
9806
9807 public:
9812 virtual QueuePriority priority() const noexcept = 0;
9813
9818 virtual QueueType type() const noexcept = 0;
9819
9820 public:
9826 static constexpr Vectors::ByteVector3 DEFAULT_DEBUG_COLOR = { 128_ui8, 128_ui8, 128_ui8 };
9827
9836 virtual void beginDebugRegion([[maybe_unused]] const String& label, [[maybe_unused]] const Vectors::ByteVector3& color = DEFAULT_DEBUG_COLOR) const noexcept { };
9837
9844 virtual void endDebugRegion() const noexcept { };
9845
9854 virtual void setDebugMarker([[maybe_unused]] const String& label, [[maybe_unused]] const Vectors::ByteVector3& color = DEFAULT_DEBUG_COLOR) const noexcept { };
9855
9856 public:
9861
9866
9880 inline SharedPtr<ICommandBuffer> createCommandBuffer(bool beginRecording = false, bool secondary = false) const {
9881 return this->getCommandBuffer(beginRecording, secondary);
9882 }
9883
9896 inline UInt64 submit(const SharedPtr<const ICommandBuffer>& commandBuffer) const {
9897 return this->submitCommandBuffer(commandBuffer);
9898 }
9899
9912 inline UInt64 submit(const SharedPtr<ICommandBuffer>& commandBuffer) const {
9913 return this->submitCommandBuffer(commandBuffer);
9914 }
9915
9929 return this->submitCommandBuffers(std::move(commandBuffers));
9930 }
9931
9940 virtual void waitFor(UInt64 fence) const = 0;
9941
9951 inline void waitFor(const ICommandQueue& queue, UInt64 fence) const {
9952 this->waitForQueue(queue, fence);
9953 }
9954
9961 virtual UInt64 currentFence() const noexcept = 0;
9962
9968 virtual UInt64 lastCompletedFence() const noexcept = 0;
9969
9970 private:
9971 virtual SharedPtr<ICommandBuffer> getCommandBuffer(bool beginRecording, bool secondary) const = 0;
9972 virtual UInt64 submitCommandBuffer(const SharedPtr<const ICommandBuffer>& commandBuffer) const = 0;
9973 virtual UInt64 submitCommandBuffers(Enumerable<SharedPtr<const ICommandBuffer>> commandBuffers) const = 0;
9974 virtual void waitForQueue(const ICommandQueue& queue, UInt64 fence) const = 0;
9975
9976 protected:
9977 inline void releaseSharedState(const ICommandBuffer& commandBuffer) const {
9978 commandBuffer.releaseSharedState();
9979 }
9980 };
9981
9985 struct LITEFX_RENDERING_API MemoryHeapStatistics {
9989 bool onGpu{ false };
9990
9994 bool cpuVisible{ false };
9995
9999 UInt32 blocks{};
10000
10004 UInt32 allocations{};
10005
10009 UInt64 blockSize{};
10010
10014 UInt64 allocationSize{};
10015
10022 UInt64 usedMemory{};
10023
10031 UInt64 availableMemory{};
10032 };
10033
10040 struct LITEFX_RENDERING_API DetailedMemoryStatistics {
10048 bool onGpu{ false };
10049
10053 bool cpuVisible{ false };
10054
10058 UInt32 blocks{};
10059
10063 UInt32 allocations{};
10064
10068 UInt64 blockSize{};
10069
10073 UInt64 allocationSize{};
10074
10078 UInt32 unusedRangeCount{};
10079
10083 UInt64 minAllocationSize{};
10084
10088 UInt64 maxAllocationSize{};
10089
10093 UInt64 minUnusedRangeSize{};
10094
10098 UInt64 maxUnusedRangeSize{};
10099 };
10100
10105
10109 Array<StatisticsBlock> perResourceHeap{};
10110
10115 };
10116
10120 class LITEFX_RENDERING_API IGraphicsFactory : public SharedObject {
10121 protected:
10122 IGraphicsFactory() noexcept = default;
10123 IGraphicsFactory(IGraphicsFactory&&) noexcept = default;
10125 IGraphicsFactory& operator=(const IGraphicsFactory&) = default;
10126 IGraphicsFactory& operator=(IGraphicsFactory&&) noexcept = default;
10127
10128 public:
10129 ~IGraphicsFactory() noexcept override = default;
10130
10131 public:
10138 [[nodiscard]] virtual VirtualAllocator createAllocator(UInt64 overallMemory, AllocationAlgorithm algorithm = AllocationAlgorithm::Default) const = 0;
10139
10168 virtual void beginDefragmentation(const ICommandQueue& queue, DefragmentationStrategy strategy = DefragmentationStrategy::Balanced, UInt64 maxBytesToMove = 0u, UInt32 maxAllocationsToMove = 0u) const = 0;
10169
10188 virtual UInt64 beginDefragmentationPass() const = 0;
10189
10203 virtual bool endDefragmentationPass() const = 0;
10204
10211 virtual ResourceAllocationResult allocate(const ResourceAllocationInfo& allocationInfo, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10212 if (std::holds_alternative<ResourceAllocationInfo::ImageInfo>(allocationInfo.ResourceInfo))
10213 {
10214 auto& imageInfo = std::get<ResourceAllocationInfo::ImageInfo>(allocationInfo.ResourceInfo);
10215 return this->createTexture(allocationInfo.Name, imageInfo.Format, imageInfo.Size, imageInfo.Dimensions, imageInfo.Levels, imageInfo.Layers, imageInfo.Samples, allocationInfo.Usage, allocationBehavior);
10216 }
10217 else
10218 {
10219 auto& bufferInfo = std::get<ResourceAllocationInfo::BufferInfo>(allocationInfo.ResourceInfo);
10220
10221 if (bufferInfo.Type == BufferType::Vertex && bufferInfo.VertexBufferLayout != nullptr)
10222 return std::dynamic_pointer_cast<IBuffer>(
10223 this->createVertexBuffer(allocationInfo.Name, *bufferInfo.VertexBufferLayout, bufferInfo.Heap, bufferInfo.Elements, allocationInfo.Usage, allocationBehavior));
10224 else if (bufferInfo.Type == BufferType::Index && bufferInfo.IndexBufferLayout != nullptr)
10225 return std::dynamic_pointer_cast<IBuffer>(
10226 this->createIndexBuffer(allocationInfo.Name, *bufferInfo.IndexBufferLayout, bufferInfo.Heap, bufferInfo.Elements, allocationInfo.Usage, allocationBehavior));
10227 else
10228 return this->createBuffer(allocationInfo.Name, bufferInfo.Type, bufferInfo.Heap, bufferInfo.ElementSize, bufferInfo.Elements, allocationInfo.Usage, allocationBehavior);
10229 }
10230 }
10231
10253 virtual Generator<ResourceAllocationResult> allocate(Enumerable<const ResourceAllocationInfo&> allocationInfos, AllocationBehavior allocationBehavior = AllocationBehavior::Default, bool alias = false) const = 0;
10254
10262 virtual bool canAlias(Enumerable<const ResourceAllocationInfo&> allocationInfos) const = 0;
10263
10274 inline SharedPtr<IBuffer> createBuffer(BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10275 return this->getBuffer(type, heap, elementSize, elements, usage, allocationBehavior);
10276 };
10277
10289 inline bool tryCreateBuffer(SharedPtr<IBuffer>& buffer, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10290 return this->tryGetBuffer(buffer, type, heap, elementSize, elements, usage, allocationBehavior);
10291 };
10292
10303 inline SharedPtr<IBuffer> createBuffer(const IDescriptorSetLayout& descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10304 auto& descriptor = descriptorSet.descriptor(binding);
10305 return this->createBuffer(descriptor.type(), heap, descriptor.elementSize(), elements, usage, allocationBehavior);
10306 };
10307
10319 inline bool tryCreateBuffer(SharedPtr<IBuffer>& buffer,const IDescriptorSetLayout& descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10320 auto& descriptor = descriptorSet.descriptor(binding);
10321 return this->tryCreateBuffer(buffer, descriptor.type(), heap, descriptor.elementSize(), elements, usage, allocationBehavior);
10322 };
10323
10334 inline SharedPtr<IBuffer> createBuffer(const IDescriptorSetLayout& descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elementSize, UInt32 elements, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10335 auto& descriptor = descriptorSet.descriptor(binding);
10336 return this->createBuffer(descriptor.type(), heap, elementSize, elements, usage, allocationBehavior);
10337 };
10338
10350 inline bool tryCreateBuffer(SharedPtr<IBuffer>& buffer, const IDescriptorSetLayout& descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elementSize, UInt32 elements, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10351 auto& descriptor = descriptorSet.descriptor(binding);
10352 return this->tryCreateBuffer(buffer, descriptor.type(), heap, elementSize, elements, usage, allocationBehavior);
10353 };
10354
10366 inline SharedPtr<IBuffer> createBuffer(const IPipeline& pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elementSize, UInt32 elements, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10367 return this->createBuffer(pipeline.layout()->descriptorSet(space), binding, heap, elementSize, elements, usage, allocationBehavior);
10368 };
10369
10382 inline bool tryCreateBuffer(SharedPtr<IBuffer>& buffer, const IPipeline& pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elementSize, UInt32 elements, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10383 return this->tryCreateBuffer(buffer, pipeline.layout()->descriptorSet(space), binding, heap, elementSize, elements, usage, allocationBehavior);
10384 };
10385
10397 inline SharedPtr<IBuffer> createBuffer(const IPipeline& pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10398 return this->createBuffer(pipeline.layout()->descriptorSet(space), binding, heap, elements, usage, allocationBehavior);
10399 };
10400
10413 inline bool tryCreateBuffer(SharedPtr<IBuffer>& buffer, const IPipeline& pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10414 return this->tryCreateBuffer(buffer, pipeline.layout()->descriptorSet(space), binding, heap, elements, usage, allocationBehavior);
10415 };
10416
10428 inline SharedPtr<IBuffer> createBuffer(const String& name, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10429 return this->getBuffer(name, type, heap, elementSize, elements, usage, allocationBehavior);
10430 };
10431
10444 inline bool tryCreateBuffer(SharedPtr<IBuffer>& buffer, const String& name, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10445 return this->tryGetBuffer(buffer, name, type, heap, elementSize, elements, usage, allocationBehavior);
10446 };
10447
10459 inline SharedPtr<IBuffer> createBuffer(const String& name, const IDescriptorSetLayout& descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10460 auto& descriptor = descriptorSet.descriptor(binding);
10461 return this->createBuffer(name, descriptor.type(), heap, descriptor.elementSize(), elements, usage, allocationBehavior);
10462 };
10463
10476 inline bool tryCreateBuffer(SharedPtr<IBuffer>& buffer, const String& name, const IDescriptorSetLayout& descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10477 auto& descriptor = descriptorSet.descriptor(binding);
10478 return this->tryCreateBuffer(buffer, name, descriptor.type(), heap, descriptor.elementSize(), elements, usage, allocationBehavior);
10479 };
10480
10493 inline SharedPtr<IBuffer> createBuffer(const String& name, const IDescriptorSetLayout& descriptorSet, UInt32 binding, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10494 auto& descriptor = descriptorSet.descriptor(binding);
10495 return this->createBuffer(name, descriptor.type(), heap, elementSize, elements, usage, allocationBehavior);
10496 };
10497
10511 inline bool tryCreateBuffer(SharedPtr<IBuffer>& buffer, const String& name, const IDescriptorSetLayout& descriptorSet, UInt32 binding, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10512 auto& descriptor = descriptorSet.descriptor(binding);
10513 return this->tryCreateBuffer(buffer, name, descriptor.type(), heap, elementSize, elements, usage, allocationBehavior);
10514 };
10515
10528 inline SharedPtr<IBuffer> createBuffer(const String& name, const IPipeline& pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10529 return this->createBuffer(name, pipeline.layout()->descriptorSet(space), binding, heap, elements, usage, allocationBehavior);
10530 };
10531
10545 inline bool tryCreateBuffer(SharedPtr<IBuffer>& buffer, const String& name, const IPipeline& pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10546 return this->tryCreateBuffer(buffer, name, pipeline.layout()->descriptorSet(space), binding, heap, elements, usage, allocationBehavior);
10547 };
10548
10562 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, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10563 return this->createBuffer(name, pipeline.layout()->descriptorSet(space), binding, heap, elementSize, elements, usage, allocationBehavior);
10564 };
10565
10580 inline bool tryCreateBuffer(SharedPtr<IBuffer>& buffer, const String& name, const IPipeline& pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, size_t elementSize, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10581 return this->tryCreateBuffer(buffer, name, pipeline.layout()->descriptorSet(space), binding, heap, elementSize, elements, usage, allocationBehavior);
10582 };
10583
10598 inline SharedPtr<IVertexBuffer> createVertexBuffer(const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10599 return this->getVertexBuffer(layout, heap, elements, usage, allocationBehavior);
10600 }
10601
10612 inline bool tryCreateVertexBuffer(SharedPtr<IVertexBuffer>& buffer, const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10613 return this->tryGetVertexBuffer(buffer, layout, heap, elements, usage, allocationBehavior);
10614 }
10615
10631 inline SharedPtr<IVertexBuffer> createVertexBuffer(const String& name, const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10632 return this->getVertexBuffer(name, layout, heap, elements, usage, allocationBehavior);
10633 }
10634
10646 inline bool tryCreateVertexBuffer(SharedPtr<IVertexBuffer>& buffer, const String& name, const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements = 1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10647 return this->tryGetVertexBuffer(buffer, name, layout, heap, elements, usage, allocationBehavior);
10648 }
10649
10664 inline SharedPtr<IIndexBuffer> createIndexBuffer(const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10665 return this->getIndexBuffer(layout, heap, elements, usage, allocationBehavior);
10666 }
10667
10678 inline bool tryCreateIndexBuffer(SharedPtr<IIndexBuffer>& buffer, const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10679 return this->tryGetIndexBuffer(buffer, layout, heap, elements, usage, allocationBehavior);
10680 }
10681
10697 inline SharedPtr<IIndexBuffer> createIndexBuffer(const String& name, const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10698 return this->getIndexBuffer(name, layout, heap, elements, usage, allocationBehavior);
10699 }
10700
10712 inline bool tryCreateIndexBuffer(SharedPtr<IIndexBuffer>& buffer, const String& name, const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10713 return this->tryGetIndexBuffer(buffer, name, layout, heap, elements, usage, allocationBehavior);
10714 }
10715
10733 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, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10734 return this->getTexture(format, size, dimension, levels, layers, samples, usage, allocationBehavior);
10735 }
10736
10750 inline bool tryCreateTexture(SharedPtr<IImage>& image, Format format, const Size3d& size, ImageDimensions dimension = ImageDimensions::DIM_2, UInt32 levels = 1, UInt32 layers = 1, MultiSamplingLevel samples = MultiSamplingLevel::x1, ResourceUsage usage = ResourceUsage::Default, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10751 return this->tryGetTexture(image, format, size, dimension, levels, layers, samples, usage, allocationBehavior);
10752 }
10753
10772 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, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10773 return this->getTexture(name, format, size, dimension, levels, layers, samples, usage, allocationBehavior);
10774 }
10775
10790 inline bool tryCreateTexture(SharedPtr<IImage>& image, 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, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10791 return this->tryGetTexture(image, name, format, size, dimension, levels, layers, samples, usage, allocationBehavior);
10792 }
10793
10806 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, AllocationBehavior allocationBehavior = AllocationBehavior::Default) const {
10807 return this->getTextures(format, size, dimension, layers, levels, samples, usage, allocationBehavior);
10808 }
10809
10825 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 {
10826 return this->getSampler(magFilter, minFilter, borderU, borderV, borderW, mipMapMode, mipMapBias, maxLod, minLod, anisotropy);
10827 }
10828
10845 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 {
10846 return this->getSampler(name, magFilter, minFilter, borderU, borderV, borderW, mipMapMode, mipMapBias, maxLod, minLod, anisotropy);
10847 }
10848
10864 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 {
10865 return this->getSamplers(magFilter, minFilter, borderU, borderV, borderW, mipMapMode, mipMapBias, maxLod, minLod, anisotropy);
10866 }
10867
10878 return this->createBottomLevelAccelerationStructure("", flags);
10879 }
10880
10892 return this->getBlas(name, flags);
10893 }
10894
10905 return this->createTopLevelAccelerationStructure("", flags);
10906 }
10907
10919 return this->getTlas(name, flags);
10920 }
10921
10930 virtual bool supportsResizableBaseAddressRegister() const noexcept = 0;
10931
10936 virtual Array<MemoryHeapStatistics> memoryStatistics() const = 0;
10937
10946 virtual DetailedMemoryStatistics detailedMemoryStatistics() const = 0;
10947
10948 private:
10949 virtual SharedPtr<IBuffer> getBuffer(BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10950 virtual SharedPtr<IBuffer> getBuffer(const String& name, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10951 virtual SharedPtr<IVertexBuffer> getVertexBuffer(const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10952 virtual SharedPtr<IVertexBuffer> getVertexBuffer(const String& name, const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10953 virtual SharedPtr<IIndexBuffer> getIndexBuffer(const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10954 virtual SharedPtr<IIndexBuffer> getIndexBuffer(const String& name, const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10955 virtual SharedPtr<IImage> getTexture(Format format, const Size3d& size, ImageDimensions dimension, UInt32 levels, UInt32 layers, MultiSamplingLevel samples, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10956 virtual SharedPtr<IImage> getTexture(const String& name, Format format, const Size3d& size, ImageDimensions dimension, UInt32 levels, UInt32 layers, MultiSamplingLevel samples, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10957 virtual bool tryGetBuffer(SharedPtr<IBuffer>& buffer, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10958 virtual bool tryGetBuffer(SharedPtr<IBuffer>& buffer, const String& name, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10959 virtual bool tryGetVertexBuffer(SharedPtr<IVertexBuffer>& buffer, const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10960 virtual bool tryGetVertexBuffer(SharedPtr<IVertexBuffer>& buffer, const String& name, const IVertexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10961 virtual bool tryGetIndexBuffer(SharedPtr<IIndexBuffer>& buffer, const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10962 virtual bool tryGetIndexBuffer(SharedPtr<IIndexBuffer>& buffer, const String& name, const IIndexBufferLayout& layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10963 virtual bool tryGetTexture(SharedPtr<IImage>& image, Format format, const Size3d& size, ImageDimensions dimension, UInt32 levels, UInt32 layers, MultiSamplingLevel samples, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10964 virtual bool tryGetTexture(SharedPtr<IImage>& image, const String& name, Format format, const Size3d& size, ImageDimensions dimension, UInt32 levels, UInt32 layers, MultiSamplingLevel samples, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10965 virtual Generator<SharedPtr<IImage>> getTextures(Format format, const Size3d& size, ImageDimensions dimension, UInt32 layers, UInt32 levels, MultiSamplingLevel samples, ResourceUsage usage, AllocationBehavior allocationBehavior) const = 0;
10966 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;
10967 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;
10968 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;
10970 virtual UniquePtr<ITopLevelAccelerationStructure> getTlas(StringView name, AccelerationStructureFlags flags) const = 0;
10971 };
10972
10983 struct LITEFX_RENDERING_API GraphicsDeviceFeatures {
10984 public:
10988 bool MeshShaders { false };
10989
10993 bool RayTracing { false };
10994
10998 bool RayQueries { false };
10999
11003 bool DrawIndirect { false };
11004
11023 bool DynamicDescriptors { false };
11024
11030 bool DepthBoundsTest { false };
11031
11037 bool ConservativeRasterization { false };
11038
11044 bool ViewInstancing { false };
11045 };
11046
11050 class LITEFX_RENDERING_API IGraphicsDevice : public SharedObject {
11051 protected:
11052 IGraphicsDevice() noexcept = default;
11053 IGraphicsDevice(IGraphicsDevice&&) noexcept = default;
11055 IGraphicsDevice& operator=(const IGraphicsDevice&) = default;
11056 IGraphicsDevice& operator=(IGraphicsDevice&&) noexcept = default;
11057
11058 public:
11059 ~IGraphicsDevice() noexcept override = default;
11060
11061 public:
11066 virtual DeviceState& state() const noexcept = 0;
11067
11072 virtual const ISurface& surface() const noexcept = 0;
11073
11078 virtual const IGraphicsAdapter& adapter() const noexcept = 0;
11079
11084 virtual const ISwapChain& swapChain() const noexcept = 0;
11085
11090 virtual ISwapChain& swapChain() noexcept = 0;
11091
11096 virtual const IGraphicsFactory& factory() const noexcept = 0;
11097
11111 inline const ICommandQueue& defaultQueue(QueueType type) const {
11112 return this->getDefaultQueue(type);
11113 }
11114
11133 inline SharedPtr<const ICommandQueue> createQueue(QueueType type, QueuePriority priority = QueuePriority::Normal) {
11134 return this->getNewQueue(type, priority);
11135 }
11136
11143 [[nodiscard]] inline UniquePtr<IBarrier> makeBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const {
11144 return this->getNewBarrier(syncBefore, syncAfter);
11145 }
11146
11152 [[nodiscard]] inline SharedPtr<IFrameBuffer> makeFrameBuffer(const Size2d& renderArea) const {
11153 return this->makeFrameBuffer("", renderArea);
11154 }
11155
11162 [[nodiscard]] inline SharedPtr<IFrameBuffer> makeFrameBuffer(StringView name, const Size2d& renderArea) const {
11163 return this->getNewFrameBuffer(name, renderArea);
11164 }
11165
11175 virtual MultiSamplingLevel maximumMultiSamplingLevel(Format format) const noexcept = 0;
11176
11182 virtual double ticksPerMillisecond() const noexcept = 0;
11183
11198 inline void computeAccelerationStructureSizes(const IBottomLevelAccelerationStructure& blas, UInt64& bufferSize, UInt64& scratchSize, bool forUpdate = false) const {
11199 this->getAccelerationStructureSizes(blas, bufferSize, scratchSize, forUpdate);
11200 }
11201
11216 inline void computeAccelerationStructureSizes(const ITopLevelAccelerationStructure& tlas, UInt64& bufferSize, UInt64& scratchSize, bool forUpdate = false) const {
11217 this->getAccelerationStructureSizes(tlas, bufferSize, scratchSize, forUpdate);
11218 }
11219
11226 [[nodiscard]] inline VirtualAllocator::Allocation allocateGlobalDescriptors(const IDescriptorSet& descriptorSet, DescriptorHeapType heapType) const {
11227 return this->doAllocateGlobalDescriptors(descriptorSet, heapType);
11228 }
11229
11239 inline void releaseGlobalDescriptors(const IDescriptorSet& descriptorSet) const {
11240 this->doReleaseGlobalDescriptors(descriptorSet);
11241 }
11242
11250 inline void updateGlobalDescriptors(const IDescriptorSet& descriptorSet, UInt32 binding, UInt32 offset, UInt32 descriptors) const {
11251 this->doUpdateGlobalDescriptors(descriptorSet, binding, offset, descriptors);
11252 }
11253
11264 inline void bindDescriptorSet(const ICommandBuffer& commandBuffer, const IDescriptorSet& descriptorSet, const IPipeline& pipeline) const noexcept {
11265 this->doBindDescriptorSet(commandBuffer, descriptorSet, pipeline);
11266 }
11267
11272 inline void bindGlobalDescriptorHeaps(const ICommandBuffer& commandBuffer) const noexcept {
11273 this->doBindGlobalDescriptorHeaps(commandBuffer);
11274 }
11275
11276 private:
11277 virtual void getAccelerationStructureSizes(const IBottomLevelAccelerationStructure& blas, UInt64& bufferSize, UInt64& scratchSize, bool forUpdate) const = 0;
11278 virtual void getAccelerationStructureSizes(const ITopLevelAccelerationStructure& tlas, UInt64& bufferSize, UInt64& scratchSize, bool forUpdate) const = 0;
11279 virtual VirtualAllocator::Allocation doAllocateGlobalDescriptors(const IDescriptorSet& descriptorSet, DescriptorHeapType heapType) const = 0;
11280 virtual void doReleaseGlobalDescriptors(const IDescriptorSet& descriptorSet) const = 0;
11281 virtual void doUpdateGlobalDescriptors(const IDescriptorSet& descriptorSet, UInt32 binding, UInt32 offset, UInt32 descriptors) const = 0;
11282 virtual void doBindDescriptorSet(const ICommandBuffer& commandBuffer, const IDescriptorSet& descriptorSet, const IPipeline& pipeline) const noexcept = 0;
11283 virtual void doBindGlobalDescriptorHeaps(const ICommandBuffer& commandBuffer) const noexcept = 0;
11284
11285 public:
11293 virtual void wait() const = 0;
11294
11295 private:
11296 virtual UniquePtr<IBarrier> getNewBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const = 0;
11297 virtual SharedPtr<IFrameBuffer> getNewFrameBuffer(StringView name, const Size2d& renderArea) const = 0;
11298 virtual const ICommandQueue& getDefaultQueue(QueueType type) const = 0;
11299 virtual SharedPtr<const ICommandQueue> getNewQueue(QueueType type, QueuePriority priority) = 0;
11300 };
11301
11305 class LITEFX_RENDERING_API IRenderBackend : public IBackend {
11306 protected:
11307 IRenderBackend() noexcept = default;
11308 IRenderBackend(IRenderBackend&&) noexcept = default;
11310 IRenderBackend& operator=(const IRenderBackend&) = default;
11311 IRenderBackend& operator=(IRenderBackend&&) noexcept = default;
11312
11313 public:
11314 ~IRenderBackend() noexcept override = default;
11315
11316 public:
11321 inline Enumerable<SharedPtr<const IGraphicsAdapter>> listAdapters() const {
11322 return this->getAdapters();
11323 }
11324
11336 virtual const IGraphicsAdapter* findAdapter(const Optional<UInt64>& adapterId = std::nullopt) const noexcept = 0;
11337
11343 virtual IGraphicsDevice* device(const String& name) noexcept = 0;
11344
11350 virtual const IGraphicsDevice* device(const String& name) const noexcept = 0;
11351
11357 virtual inline const IGraphicsDevice* operator[](const String& name) const noexcept {
11358 return this->device(name);
11359 };
11360
11366 virtual inline IGraphicsDevice* operator[](const String& name) noexcept {
11367 return this->device(name);
11368 };
11369
11370 private:
11371 virtual Enumerable<SharedPtr<const IGraphicsAdapter>> getAdapters() const = 0;
11372 };
11373
11377 template <typename T>
11379
11380}
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:940
Definition math.hpp:864
Definition math.hpp:833
Definition math.hpp:504
Definition math.hpp:548
Stores meta data about a buffer attribute, i.e. a member or field of a descriptor or buffer.
Definition rendering_api.hpp:4437
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:3751
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:2697
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:5260
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:5341
SharedPtr< const IBuffer > buffer() const noexcept
Returns the acceleration structure backing buffer, that stores its last build.
Definition rendering_api.hpp:5351
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:5921
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:6007
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:6048
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:5989
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:5976
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:6025
A structure that holds a singular entity of geometry for hardware ray-tracing.
Definition rendering_api.hpp:5399
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:5669
auto withTriangleMesh(this TSelf &&self, const TriangleMesh &mesh) -> TSelf &&
Adds a triangle mesh to the BLAS.
Definition rendering_api.hpp:5630
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:5645
auto withBoundingBox(this TSelf &&self, const BoundingBoxes &aabb) -> TSelf &&
Adds a buffer containing axis-aligned bounding boxes to the BLAS.
Definition rendering_api.hpp:5656
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:4997
IBuffer() noexcept=default
Describes a buffer layout.
Definition rendering_api.hpp:4536
IBufferLayout() noexcept=default
The interface for a command buffer.
Definition rendering_api.hpp:7682
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:8349
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:8633
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:8413
void barrier(const IBarrier &barrier) const noexcept
Executes the transitions that have been added to barrier .
Definition rendering_api.hpp:7791
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:7985
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:8128
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:8488
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:8214
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:8601
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:7968
void dispatchMesh(UInt32 x, UInt32 y, UInt32 z) const noexcept
Executes a mesh shader pipeline.
Definition rendering_api.hpp:8307
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:7809
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:8667
virtual void dispatchMesh(const Vector3u &threadGroupCount) const noexcept=0
Executes a mesh shader pipeline.
virtual void setDepthBounds(Float minBounds, Float maxBounds) const noexcept=0
Sets the depth range for the depth bounds test.
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:8244
void execute(const SharedPtr< const ICommandBuffer > &commandBuffer) const
Executes a secondary command buffer/bundle.
Definition rendering_api.hpp:8561
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:8617
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:8111
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:8455
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:8159
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:8002
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:8174
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:8026
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:7905
void execute(Enumerable< SharedPtr< const ICommandBuffer > > commandBuffers) const
Executes a series of secondary command buffers/bundles.
Definition rendering_api.hpp:8569
void use(const IPipeline &pipeline) const noexcept
Sets the active pipeline state.
Definition rendering_api.hpp:8118
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:7833
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:8650
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:8466
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:7850
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:7951
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:8274
void dispatchIndirect(const IBuffer &batchBuffer, UInt32 batchCount, UInt64 offset=0) const noexcept
Executes a set of indirect dispatches.
Definition rendering_api.hpp:8285
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:8365
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:8318
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:7866
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:8400
UniquePtr< IBarrier > makeBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const
Creates a new barrier instance.
Definition rendering_api.hpp:7778
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:8198
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:8230
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:8183
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:8142
void bind(const IIndexBuffer &buffer) const
Binds a index buffer to the pipeline.
Definition rendering_api.hpp:8257
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:8065
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:8585
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:8479
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:8331
The interface for a command queue.
Definition rendering_api.hpp:9742
ICommandQueue() noexcept=default
Event< QueueSubmittingEventArgs > submitting
Invoked, when one or more command buffers are submitted to the queue.
Definition rendering_api.hpp:9860
Event< QueueSubmittedEventArgs > submitted
Invoked, after one or more command buffers have been submitted to the queue.
Definition rendering_api.hpp:9865
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:9836
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:9880
virtual void setDebugMarker(const String &label, const Vectors::ByteVector3 &color=DEFAULT_DEBUG_COLOR) const noexcept
Inserts a debug marker.
Definition rendering_api.hpp:9854
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:9896
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:9928
virtual void endDebugRegion() const noexcept
Ends the current debug region.
Definition rendering_api.hpp:9844
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:9951
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:9912
The interface for a compute pipeline.
Definition rendering_api.hpp:8795
Describes a the layout of a single descriptor within a DescriptorSet.
Definition rendering_api.hpp:4641
The interface for a descriptor set.
Definition rendering_api.hpp:6064
UInt32 bindToHeap(UInt32 descriptor, const ISampler &sampler) const
Binds a sampler directly to a descriptor heap and returns the index that can be used to access it.
Definition rendering_api.hpp:6141
UInt32 bindToHeap(DescriptorType bindingType, UInt32 descriptor, const IImage &image, UInt32 firstLevel=0, UInt32 levels=0, UInt32 firstLayer=0, UInt32 layers=0) const
Binds a resource directly to a descriptor heap and returns the index that can be used to access it.
Definition rendering_api.hpp:6124
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:6179
void update(UInt32 binding, const IAccelerationStructure &accelerationStructure, UInt32 descriptor=0) const
Updates an acceleration structure within the current descriptor set.
Definition rendering_api.hpp:6199
void update(UInt32 binding, const IBuffer &buffer, UInt32 bufferElement=0, UInt32 elements=0, UInt32 firstDescriptor=0, Format texelFormat=Format::None) const
Updates one or more buffer descriptors within the current descriptor set.
Definition rendering_api.hpp:6154
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:6189
The interface for a descriptor set layout.
Definition rendering_api.hpp:6290
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:6445
UniquePtr< IDescriptorSet > allocate(UInt32 descriptors, Generator< DescriptorBinding > bindings) const
Allocates an array of descriptor sets.
Definition rendering_api.hpp:6473
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:6541
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:6514
Generator< UniquePtr< IDescriptorSet > > allocate(UInt32 descriptorSets, std::function< Generator< DescriptorBinding >(UInt32)> bindingFactory) const
Allocates an array of descriptor sets.
Definition rendering_api.hpp:6502
UniquePtr< IDescriptorSet > allocate(Span< DescriptorBinding > bindings) const
Definition rendering_api.hpp:6440
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:6484
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:6533
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:6457
UniquePtr< IDescriptorSet > allocate(UInt32 descriptors, Span< DescriptorBinding > bindings) const
Definition rendering_api.hpp:6462
Describes a chunk of device memory.
Definition rendering_api.hpp:4758
virtual bool volatileMove() const noexcept
Returns true, if the contents of the resource should not be copied during a move.
Definition rendering_api.hpp:4989
IDeviceMemory() noexcept=default
The interface for a frame buffer.
Definition rendering_api.hpp:8903
Event< ResizeEventArgs > resized
Invoked after the frame buffer has been resized.
Definition rendering_api.hpp:9000
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:9094
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:9236
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:9203
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:9272
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:9191
Event< ResizeEventArgs > resizing
Invoked if the frame buffer gets resized.
Definition rendering_api.hpp:8993
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.
std::function< SharedPtr< const TImage >(Optional< UInt64 >, Size2d, ResourceUsage, Format, MultiSamplingLevel, const String &)> allocation_callback_type
A function that gets invoked as a callback, if the frame buffer needs to allocate an image.
Definition rendering_api.hpp:8925
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:9180
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:9248
Enumerable< const IImage & > images() const
Returns all images contained by the frame buffer.
Definition rendering_api.hpp:9112
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:9011
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:9225
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:3222
The interface for a graphics device that.
Definition rendering_api.hpp:11050
void bindGlobalDescriptorHeaps(const ICommandBuffer &commandBuffer) const noexcept
Binds the global descriptor heap.
Definition rendering_api.hpp:11272
SharedPtr< IFrameBuffer > makeFrameBuffer(const Size2d &renderArea) const
Creates a new frame buffer instance.
Definition rendering_api.hpp:11152
void bindDescriptorSet(const ICommandBuffer &commandBuffer, const IDescriptorSet &descriptorSet, const IPipeline &pipeline) const noexcept
Binds the descriptors of the descriptor set to the global descriptor heaps.
Definition rendering_api.hpp:11264
void releaseGlobalDescriptors(const IDescriptorSet &descriptorSet) const
Releases a range of descriptors from the global descriptor heaps.
Definition rendering_api.hpp:11239
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:11133
VirtualAllocator::Allocation allocateGlobalDescriptors(const IDescriptorSet &descriptorSet, DescriptorHeapType heapType) const
Allocates a range of descriptors in the global descriptor heaps for the provided descriptorSet .
Definition rendering_api.hpp:11226
void updateGlobalDescriptors(const IDescriptorSet &descriptorSet, UInt32 binding, UInt32 offset, UInt32 descriptors) const
Updates a range of descriptors in the global buffer descriptor heap with the descriptors from descrip...
Definition rendering_api.hpp:11250
UniquePtr< IBarrier > makeBarrier(PipelineStage syncBefore, PipelineStage syncAfter) const
Creates a memory barrier instance.
Definition rendering_api.hpp:11143
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:11216
SharedPtr< IFrameBuffer > makeFrameBuffer(StringView name, const Size2d &renderArea) const
Creates a new frame buffer instance.
Definition rendering_api.hpp:11162
The interface for a graphics factory.
Definition rendering_api.hpp:10120
bool tryCreateBuffer(SharedPtr< IBuffer > &buffer, const String &name, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a buffer of type type .
Definition rendering_api.hpp:10444
SharedPtr< IBuffer > createBuffer(const String &name, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a buffer of type type .
Definition rendering_api.hpp:10428
bool tryCreateBuffer(SharedPtr< IBuffer > &buffer, BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a buffer of type type .
Definition rendering_api.hpp:10289
bool tryCreateBuffer(SharedPtr< IBuffer > &buffer, const String &name, const IPipeline &pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, size_t elementSize, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a buffer that can be bound to a descriptor of a specific descriptor set.
Definition rendering_api.hpp:10580
SharedPtr< IIndexBuffer > createIndexBuffer(const IIndexBufferLayout &layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates an index buffer, based on the layout .
Definition rendering_api.hpp:10664
SharedPtr< IBuffer > createBuffer(const String &name, const IDescriptorSetLayout &descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a buffer that can be bound to a specific descriptor.
Definition rendering_api.hpp:10459
UniquePtr< IBottomLevelAccelerationStructure > createBottomLevelAccelerationStructure(AccelerationStructureFlags flags=AccelerationStructureFlags::None) const
Creates a bottom-level acceleration structure.
Definition rendering_api.hpp:10877
bool tryCreateBuffer(SharedPtr< IBuffer > &buffer, const String &name, const IPipeline &pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a buffer that can be bound to a descriptor of a specific descriptor set.
Definition rendering_api.hpp:10545
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:10845
bool tryCreateBuffer(SharedPtr< IBuffer > &buffer, const IPipeline &pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a buffer that can be bound to a descriptor of a specific descriptor set.
Definition rendering_api.hpp:10413
bool tryCreateBuffer(SharedPtr< IBuffer > &buffer, const IDescriptorSetLayout &descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a buffer that can be bound to a specific descriptor.
Definition rendering_api.hpp:10319
UniquePtr< ITopLevelAccelerationStructure > createTopLevelAccelerationStructure(StringView name, AccelerationStructureFlags flags=AccelerationStructureFlags::None) const
Creates a top-level acceleration structure.
Definition rendering_api.hpp:10918
SharedPtr< IBuffer > createBuffer(const IDescriptorSetLayout &descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a buffer that can be bound to a specific descriptor.
Definition rendering_api.hpp:10303
bool tryCreateBuffer(SharedPtr< IBuffer > &buffer, const IDescriptorSetLayout &descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elementSize, UInt32 elements, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a buffer that can be bound to a specific descriptor.
Definition rendering_api.hpp:10350
SharedPtr< IVertexBuffer > createVertexBuffer(const IVertexBufferLayout &layout, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a vertex buffer, based on the layout .
Definition rendering_api.hpp:10598
SharedPtr< IBuffer > createBuffer(BufferType type, ResourceHeap heap, size_t elementSize, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a buffer of type type .
Definition rendering_api.hpp:10274
bool tryCreateTexture(SharedPtr< IImage > &image, Format format, const Size3d &size, ImageDimensions dimension=ImageDimensions::DIM_2, UInt32 levels=1, UInt32 layers=1, MultiSamplingLevel samples=MultiSamplingLevel::x1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a texture.
Definition rendering_api.hpp:10750
bool tryCreateBuffer(SharedPtr< IBuffer > &buffer, const String &name, const IDescriptorSetLayout &descriptorSet, UInt32 binding, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a buffer that can be bound to a specific descriptor.
Definition rendering_api.hpp:10511
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, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a texture.
Definition rendering_api.hpp:10733
SharedPtr< IBuffer > createBuffer(const String &name, const IPipeline &pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a buffer that can be bound to a descriptor of a specific descriptor set.
Definition rendering_api.hpp:10528
bool tryCreateIndexBuffer(SharedPtr< IIndexBuffer > &buffer, const String &name, const IIndexBufferLayout &layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create an index buffer, based on the layout .
Definition rendering_api.hpp:10712
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:10864
virtual bool canAlias(Enumerable< const ResourceAllocationInfo & > allocationInfos) const =0
Checks if the resources described by allocationInfos can be overlapped.
virtual bool supportsResizableBaseAddressRegister() const noexcept=0
Returns true, if the GPU supports resizable base address register (ReBAR) and false otherwise.
SharedPtr< IBuffer > createBuffer(const IPipeline &pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a buffer that can be bound to a descriptor of a specific descriptor set.
Definition rendering_api.hpp:10397
bool tryCreateTexture(SharedPtr< IImage > &image, 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, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a texture.
Definition rendering_api.hpp:10790
bool tryCreateVertexBuffer(SharedPtr< IVertexBuffer > &buffer, const String &name, const IVertexBufferLayout &layout, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a vertex buffer, based on the layout .
Definition rendering_api.hpp:10646
SharedPtr< IBuffer > createBuffer(const String &name, const IDescriptorSetLayout &descriptorSet, UInt32 binding, ResourceHeap heap, size_t elementSize, UInt32 elements, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a buffer that can be bound to a specific descriptor.
Definition rendering_api.hpp:10493
SharedPtr< IIndexBuffer > createIndexBuffer(const String &name, const IIndexBufferLayout &layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates an index buffer, based on the layout .
Definition rendering_api.hpp:10697
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:10825
SharedPtr< IBuffer > createBuffer(const IDescriptorSetLayout &descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elementSize, UInt32 elements, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a buffer that can be bound to a specific descriptor.
Definition rendering_api.hpp:10334
bool tryCreateVertexBuffer(SharedPtr< IVertexBuffer > &buffer, const IVertexBufferLayout &layout, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a vertex buffer, based on the layout .
Definition rendering_api.hpp:10612
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, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a buffer that can be bound to a descriptor of a specific descriptor set.
Definition rendering_api.hpp:10562
SharedPtr< IVertexBuffer > createVertexBuffer(const String &name, const IVertexBufferLayout &layout, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a vertex buffer, based on the layout .
Definition rendering_api.hpp:10631
UniquePtr< IBottomLevelAccelerationStructure > createBottomLevelAccelerationStructure(StringView name, AccelerationStructureFlags flags=AccelerationStructureFlags::None) const
Creates a bottom-level acceleration structure.
Definition rendering_api.hpp:10891
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, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a series of textures.
Definition rendering_api.hpp:10806
SharedPtr< IBuffer > createBuffer(const IPipeline &pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elementSize, UInt32 elements, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a buffer that can be bound to a descriptor of a specific descriptor set.
Definition rendering_api.hpp:10366
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, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Creates a texture.
Definition rendering_api.hpp:10772
bool tryCreateBuffer(SharedPtr< IBuffer > &buffer, const String &name, const IDescriptorSetLayout &descriptorSet, UInt32 binding, ResourceHeap heap, UInt32 elements=1, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a buffer that can be bound to a specific descriptor.
Definition rendering_api.hpp:10476
UniquePtr< ITopLevelAccelerationStructure > createTopLevelAccelerationStructure(AccelerationStructureFlags flags=AccelerationStructureFlags::None) const
Creates a top-level acceleration structure.
Definition rendering_api.hpp:10904
bool tryCreateBuffer(SharedPtr< IBuffer > &buffer, const IPipeline &pipeline, UInt32 space, UInt32 binding, ResourceHeap heap, UInt32 elementSize, UInt32 elements, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create a buffer that can be bound to a descriptor of a specific descriptor set.
Definition rendering_api.hpp:10382
bool tryCreateIndexBuffer(SharedPtr< IIndexBuffer > &buffer, const IIndexBufferLayout &layout, ResourceHeap heap, UInt32 elements, ResourceUsage usage=ResourceUsage::Default, AllocationBehavior allocationBehavior=AllocationBehavior::Default) const
Tries to create an index buffer, based on the layout .
Definition rendering_api.hpp:10678
virtual Generator< ResourceAllocationResult > allocate(Enumerable< const ResourceAllocationInfo & > allocationInfos, AllocationBehavior allocationBehavior=AllocationBehavior::Default, bool alias=false) const =0
Allocates a set of resources as described by allocationInfos .
Describes a generic image.
Definition rendering_api.hpp:5019
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:5123
IImage() noexcept=default
The interface for an index buffer.
Definition rendering_api.hpp:5236
IIndexBuffer() noexcept=default
Describes a index buffer layout.
Definition rendering_api.hpp:4603
The interface for an input assembler state.
Definition rendering_api.hpp:7596
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:4692
IMappable() noexcept=default
The interface for a pipeline.
Definition rendering_api.hpp:7646
IPipeline() noexcept=default
SharedPtr< const IPipelineLayout > layout() const noexcept
Returns the layout of the render pipeline.
Definition rendering_api.hpp:7670
The interface for a pipeline layout.
Definition rendering_api.hpp:7538
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:6609
Describes a range within a IPushConstantsLayout.
Definition rendering_api.hpp:6561
Represents the rasterizer state of a RenderPipeline.
Definition rendering_api.hpp:3941
IRasterizer() noexcept=default
The interface for a ray tracing pipeline.
Definition rendering_api.hpp:8810
The interface to access a render backend.
Definition rendering_api.hpp:11305
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:11357
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:11366
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:9292
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:9393
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:9369
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:9381
IRenderPass() noexcept=default
virtual UInt64 end() const =0
Ends the render pass.
virtual UInt32 viewMask() const noexcept=0
Returns the mask that identifies the views that are enabled during rendering.
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:8725
SharedPtr< IRasterizer > rasterizer() const noexcept
Returns the rasterizer state used by the render pipeline.
Definition rendering_api.hpp:8749
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:3427
IRenderTarget() noexcept=default
Describes a texture sampler.
Definition rendering_api.hpp:5135
ISampler() noexcept=default
The interface of a scissor.
Definition rendering_api.hpp:4207
IScissor() noexcept=default
Represents a single shader module, i.e. a part of a IShaderProgram.
Definition rendering_api.hpp:3363
IShaderModule() noexcept=default
The interface for a shader program.
Definition rendering_api.hpp:7437
Enumerable< const IShaderModule & > modules() const
Returns the modules, the shader program is build from.
Definition rendering_api.hpp:7488
ShaderRecordCollection buildShaderRecordCollection() const noexcept
Builds a shader record collection based on the current shader program.
Definition rendering_api.hpp:7526
IShaderProgram() noexcept=default
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:7469
SharedPtr< IPipelineLayout > reflectPipelineLayout(Enumerable< PipelineBindingHint > hints={}) const
Uses shader reflection to extract the pipeline layout of a shader. May not be available in all backen...
Definition rendering_api.hpp:7518
bool contains(const IShaderModule &module) const
Returns true, if the program contains the provided shader module and false otherwise.
Definition rendering_api.hpp:7479
The interface for a state resource.
Definition rendering_api.hpp:2625
IStateResource() noexcept=default
Represents a surface to render to.
Definition rendering_api.hpp:3294
ISurface() noexcept=default
Interface for a swap chain.
Definition rendering_api.hpp:9484
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:9701
virtual Enumerable< Format > getSurfaceFormats() const =0
Returns an array of supported formats, that can be drawn to the surface.
Event< BackBufferSwapEventArgs > swapped
Invoked, when the swap chain has swapped the back buffers.
Definition rendering_api.hpp:9695
ISwapChain() noexcept=default
virtual Format surfaceFormat() const noexcept=0
Returns the swap chain image format.
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:5681
void addInstance(const SharedPtr< const IBottomLevelAccelerationStructure > &blas, const TMatrix3x4< Float > &transform, UInt32 id, UInt32 hitGroupOffset=0, UInt8 mask=0xFF, InstanceFlags flags=InstanceFlags::None) noexcept
Adds an instance to the TLAS.
Definition rendering_api.hpp:5777
auto withInstance(this TSelf &&self, const Instance &instance) noexcept -> TSelf &&
Adds an instance to the current TLAS.
Definition rendering_api.hpp:5838
virtual void clear() noexcept=0
Clears all instances from the acceleration structure.
auto withInstance(this TSelf &&self, const SharedPtr< const IBottomLevelAccelerationStructure > &blas, const TMatrix3x4< Float > &transform, UInt32 id, UInt32 hitGroupOffset=0, UInt8 mask=0xFF, InstanceFlags flags=InstanceFlags::None) noexcept -> TSelf &&
Adds an instance to the current TLAS.
Definition rendering_api.hpp:5869
auto withInstance(this TSelf &&self, const SharedPtr< const IBottomLevelAccelerationStructure > &blas, UInt32 id, UInt32 hitGroupOffset=0, UInt8 mask=0xFF, InstanceFlags flags=InstanceFlags::None) noexcept -> TSelf &&
Adds an instance to the current TLAS.
Definition rendering_api.hpp:5853
The interface for a vertex buffer.
Definition rendering_api.hpp:5214
IVertexBuffer() noexcept=default
Describes a vertex buffer layout.
Definition rendering_api.hpp:4574
Interface for a viewport.
Definition rendering_api.hpp:4089
IViewport() noexcept=default
Describes an index buffer.
Definition rendering.hpp:501
Implements a IRasterizer.
Definition rendering_api.hpp:4006
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:1042
Represents a mapping between a set of RenderTarget instances and the input attachments of a IRenderPa...
Definition rendering_api.hpp:3684
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:3584
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:4235
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:6923
void addShaderRecord(const ShaderRecord<>::shader_group_type &shaderGroup)
Adds a new shader record to the shader record collection.
Definition rendering_api.hpp:7068
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:7017
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:7092
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:7055
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:7037
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:7109
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:7134
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:7120
void addShaderRecord(ShaderRecord< TLocalData >::shader_group_type shaderGroup, TLocalData payload)
Adds a new shader record to the shader record collection.
Definition rendering_api.hpp:7079
ShaderRecordCollection && withShaderRecord(ShaderRecord< TLocalData >::shader_group_type shaderGroup, TLocalData payload)
Adds a new shader record to the shader record collection.
Definition rendering_api.hpp:7157
ShaderRecordCollection && withShaderRecord(ShaderRecord<>::shader_group_type shaderGroup)
Adds a new shader record to the shader record collection.
Definition rendering_api.hpp:7144
Base class for a resource that can be identified by a name string within a DeviceState.
Definition rendering_api.hpp:2650
StateResource(StateResource &&) noexcept
An event that is used to measure timestamps in a command queue.
Definition rendering_api.hpp:4371
~TimingEvent() noexcept override
Releases the render target instance.
Describes a vertex buffer.
Definition rendering.hpp:477
Implements a viewport.
Definition rendering_api.hpp:4141
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.
Represents a virtual allocator that manages memory distribution from a piece of raw memory.
Definition rendering_api.hpp:3032
VirtualAllocator(const VirtualAllocator &)=delete
Allocation allocate(UInt64 size, UInt32 alignment=1u, AllocationStrategy strategy=AllocationStrategy::OptimizePacking, void *privateData=nullptr) const
Allocates a piece of memory of size bytes, aligned to alignment .
Definition rendering_api.hpp:3190
AllocationAlgorithm algorithm() const noexcept
Returns the algorithm used by the allocator.
Definition rendering_api.hpp:3178
void * privateData(const Allocation &allocation) const
Returns the private data associated with an allocation.
Definition rendering_api.hpp:3210
void free(Allocation &&allocation) const
Releases an allocation from the allocator, so that its memory can be re-used later.
Definition rendering_api.hpp:3201
VirtualAllocator(VirtualAllocator &&) noexcept=delete
UInt64 size() const noexcept
Returns the size of the memory managed by the virtual allocator.
Definition rendering_api.hpp:3170
Implements the IResource interface.
Definition containers.hpp:823
An exception that is thrown, if a requested operation could not be executed.
Definition exceptions.hpp:235
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:11378
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:51
uint8_t UInt8
A type for an unsigned 8 bit integer.
Definition math.hpp:41
uint64_t UInt64
A type for an unsigned 64 bit integer.
Definition math.hpp:71
float_t Float
A type for a floating point value with single precision.
Definition math.hpp:76
uint32_t UInt32
A type for an unsigned 32 bit integer.
Definition math.hpp:61
int32_t Int32
A type for a signed 32 bit integer.
Definition math.hpp:56
Definition dx12.hpp:11
BorderMode
Describes how to treat texture coordinates that are outside the domain [0..1].
Definition rendering_api.hpp:1356
@ 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:1190
@ CounterClockWise
Vertices are evaluated in a counter clock-wise manner.
@ ClockWise
Vertices are evaluated in a clock-wise manner.
DescriptorHeapType
The target heap type for a descriptor.
Definition rendering_api.hpp:580
RenderTargetFlags
Describes the behavior of render targets.
Definition rendering_api.hpp:1228
@ 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:1858
@ 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:1341
BlendFactor
Specifies a blend factor.
Definition rendering_api.hpp:1479
CullMode
Describes which faces are culled by the Rasterizer stage.
Definition rendering_api.hpp:1163
@ 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:971
@ 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:1205
@ 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:2099
GraphicsAdapterType
Defines different types of graphics adapters.
Definition rendering_api.hpp:76
@ 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:1387
@ 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:1531
IndexType
Describes the element type of an index buffer.
Definition rendering_api.hpp:906
PrimitiveTopology
Describes the topology of a mesh primitive.
Definition rendering_api.hpp:937
@ 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:1111
@ 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:1142
@ 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:601
@ 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).
DefragmentationStrategy
The strategy to apply to a defragmentation pass.
Definition rendering_api.hpp:886
@ Full
Provides optimal packing at the cost of potentially more copies.
@ Balanced
Provides a balance between fragment computation time and packing efficiency.
@ Fast
Provides fast fragment computation, but potentially suboptimal packing.
InstanceFlags
Controls how an instance within a ITopLevelAccelerationStructure behaves during ray-tracing.
Definition rendering_api.hpp:2029
@ 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:372
@ BlendIndices
The attribute contains blend indices.
@ PointSize
The attribute contains a point size.
@ Binormal
The attribute contains a bi-normal vector.
@ Arbitrary
The attribute contains arbitrary data, that does not have any semantic associated with it.
@ 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:2107
ResourceUsage
Describes the intended usage for a resource.
Definition rendering_api.hpp:761
@ FrameBufferImage
Default usage for frame buffer images.
@ Volatile
Causes the contents of the resource to not be copied during defragmentation.
@ 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:1966
@ 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:1258
@ 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:2284
AllocationAlgorithm
The allocation algorithm used by VirtualAllocators.
Definition rendering_api.hpp:852
@ Linear
A linear allocation algorithm, that allocates memory blocks sequentially.
DescriptorType
Describes the type of a IDescriptor.
Definition rendering_api.hpp:442
@ RWStructuredBuffer
A writable shader storage object in Vulkan. Maps to a read/write structured buffer in DirectX.
@ SamplerDescriptorHeap
A special descriptor type that allows indexed access to the a portion of the global sampler heap.
@ 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.
@ ResourceDescriptorHeap
Special descriptor type, that can bind all resources besides constant buffers, acceleration structure...
@ 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.
AllocationStrategy
The allocation strategy used by allocators (IGraphicsFactory and VirtualAllocator) when allocating ne...
Definition rendering_api.hpp:869
@ OptimizeTime
Prefers allocation time over packing.
@ OptimizePacking
Prefers good packing over allocation time and reduces fragmentation.
QueuePriority
Specifies the priority with which a queue is scheduled on the GPU.
Definition rendering_api.hpp:160
@ 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:114
@ 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:710
@ 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.
@ GPUUpload
Creates a buffer that is directly allocated in GPU memory, but that can be efficiently written from t...
StencilOperation
An operation that is applied to the stencil buffer.
Definition rendering_api.hpp:1433
@ 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:1988
@ 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:2321
FilterMode
Describes the filter operation when accessing a pixel from a texture coordinate.
Definition rendering_api.hpp:1324
@ Nearest
Take the nearest texel with respect to the texture coordinate.
AllocationBehavior
Controls the allocation behavior of IGraphicsFactory.
Definition rendering_api.hpp:830
@ DontExpandCache
Does not resize heap cache, if no more pre-allocated memory is available and will fail,...
@ StayWithinBudget
Stays within heap budgets. If the desired resource heap is out of memory, allocation will fail....
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:6763
ShaderRecordType
Describes the type of a shader module record within a shader collection or shader binting table.
Definition rendering_api.hpp:1075
@ HitGroup
Represents a hit group shader record.
VertexBufferInputRate
The rate at which a vertex buffer of a certain IVertexBufferLayout is made available for vertex shade...
Definition rendering_api.hpp:922
PipelineStage
Defines pipeline stages as points where synchronization may occur.
Definition rendering_api.hpp:1545
@ 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:340
constexpr bool hasStencil(Format format) noexcept
Returns true, if the format contains a stencil channel.
Definition rendering_api.hpp:2301
constexpr UInt32 getBufferFormatChannels(BufferFormat format)
Returns the number of channels for a buffer format.
Definition rendering_api.hpp:2091
constexpr size_t getSize(Format format)
Returns the size of an element of a specified format.
Definition rendering_api.hpp:2114
ResourceAccess
Defines how a IBuffer or IImage resource is accessed.
Definition rendering_api.hpp:1709
@ 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:1505
@ 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:183
MultiSamplingLevel
Describes the number of samples with which a IImage is sampled.
Definition rendering_api.hpp:1283
@ 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
void * Handle
Represents a handle type.
Definition containers.hpp:58
Definition sample.cpp:21
Definition input_assembler.cpp:19
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:3797
Describes the rasterizer depth state.
Definition rendering_api.hpp:3758
Describes the rasterizer stencil state.
Definition rendering_api.hpp:3849
Describes a stencil test for either front or back faces.
Definition rendering_api.hpp:3823
Describes a resource binding to a descriptor or descriptor set.
Definition rendering_api.hpp:6218
Variant< std::monostate, Ref< const IBuffer >, Ref< const IImage >, Ref< const ISampler >, Ref< const IAccelerationStructure > > resource_container
Definition rendering_api.hpp:6220
Describes a single descriptor binding point within a IShaderModule.
Definition rendering_api.hpp:3309
bool operator==(const DescriptorBindingPoint &other) const noexcept
Implements equality comparison for descriptor binding points.
Definition rendering_api.hpp:3351
auto operator<=>(const DescriptorBindingPoint &other) const noexcept
Implements three-way comparison for descriptor binding points.
Definition rendering_api.hpp:3331
Defines a single statistics block.
Definition rendering_api.hpp:10044
Stores extended memory statistics, that can be queried by calling IGraphicsFactory::detailedMemorySta...
Definition rendering_api.hpp:10040
Describes optional features that can be supported by a device.
Definition rendering_api.hpp:10983
Stores a buffer that contains axis-aligned bounding boxes.
Definition rendering_api.hpp:5481
GeometryFlags Flags
The flags that control how the primitives in the geometry behaves during ray-tracing.
Definition rendering_api.hpp:5503
SharedPtr< const IBuffer > Buffer
A buffer containing the bounding box definitions.
Definition rendering_api.hpp:5498
Represents a triangle mesh.
Definition rendering_api.hpp:5404
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:5413
~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:9774
QueueSubmittedEventArgs(QueueSubmittedEventArgs &&) noexcept=default
QueueSubmittedEventArgs(UInt64 fence) noexcept
Definition rendering_api.hpp:9779
QueueSubmittedEventArgs(const QueueSubmittedEventArgs &)=default
Event arguments for a ICommandQueue::submitting event.
Definition rendering_api.hpp:9747
QueueSubmittingEventArgs(QueueSubmittingEventArgs &&) noexcept=default
QueueSubmittingEventArgs(Array< SharedPtr< const ICommandBuffer > > &&commandBuffers)
Definition rendering_api.hpp:9752
QueueSubmittingEventArgs(const QueueSubmittingEventArgs &)=default
Stores a reference to a barrier that can be used to synchronize accesses to the resource with a move ...
Definition rendering_api.hpp:4764
PrepareMoveEventArgs(const PrepareMoveEventArgs &)=delete
PrepareMoveEventArgs(PrepareMoveEventArgs &&) noexcept=delete
IBarrier & barrier() const noexcept
Returns a reference of the barrier that is used to synchronize the move operation with other accesses...
Definition rendering_api.hpp:4792
Stores the fence and the command queue to wait on for the fence before a moved resource can be used.
Definition rendering_api.hpp:4801
ResourceMovingEventArgs(ResourceMovingEventArgs &&) noexcept=default
ResourceMovingEventArgs(SharedPtr< const ICommandQueue > queue, UInt64 fence) noexcept
Creates a new instance of the resource moving event arguments.
Definition rendering_api.hpp:4812
ResourceMovingEventArgs(const ResourceMovingEventArgs &)=default
UInt64 fence() const noexcept
Returns the fence on queue after which the resource can be used.
Definition rendering_api.hpp:4836
Event arguments that are published to subscribers when a frame buffer gets released.
Definition rendering_api.hpp:8961
ReleasedEventArgs(ReleasedEventArgs &&) noexcept=default
ReleasedEventArgs() noexcept
Definition rendering_api.hpp:8963
ReleasedEventArgs(const ReleasedEventArgs &)=default
Event arguments that are published to subscribers when a frame buffer gets resized.
Definition rendering_api.hpp:8933
ResizeEventArgs(Size2d newSize) noexcept
Definition rendering_api.hpp:8938
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:9298
BeginEventArgs(const IFrameBuffer &frameBuffer) noexcept
Definition rendering_api.hpp:9303
BeginEventArgs(BeginEventArgs &&) noexcept=default
BeginEventArgs(const BeginEventArgs &)=default
Describes the blend state of the render target.
Definition rendering_api.hpp:3432
Describes a hit group for a triangle mesh geometry.
Definition rendering_api.hpp:6672
const IShaderModule * AnyHitShader
The any hit shader for the triangle mesh.
Definition rendering_api.hpp:6681
const IShaderModule * ClosestHitShader
The closest hit shader for the triangle mesh.
Definition rendering_api.hpp:6676
Describes a record within a shader binding table.
Definition rendering_api.hpp:6662
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:6687
Event arguments for a ISwapChain::swapped event.
Definition rendering_api.hpp:9542
BackBufferSwapEventArgs(BackBufferSwapEventArgs &&) noexcept=default
BackBufferSwapEventArgs(UInt32 backBuffer) noexcept
Definition rendering_api.hpp:9547
BackBufferSwapEventArgs(const BackBufferSwapEventArgs &)=default
Event arguments for a ISwapChain::reseted event.
Definition rendering_api.hpp:9489
ResetEventArgs(const ResetEventArgs &)=default
const Size2d & renderArea() const noexcept
Gets the new render area of the swap chain back-buffers.
Definition rendering_api.hpp:9518
ResetEventArgs(Format surfaceFormat, Size2d renderArea, UInt32 buffers, bool enableVsync) noexcept
Definition rendering_api.hpp:9497
ResetEventArgs(ResetEventArgs &&) noexcept=default
UInt32 buffers() const noexcept
Gets the number of back-buffers in the swap chain.
Definition rendering_api.hpp:9526
bool enableVsync() const noexcept
Returns true if vertical synchronization is enabled or false otherwise.
Definition rendering_api.hpp:9534
Represents an instance of an IBottomLevelAccelerationStructure.
Definition rendering_api.hpp:5688
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:5723
UInt32 Id
The instance ID used in shaders to identify the instance.
Definition rendering_api.hpp:5702
InstanceFlags Flags
The flags that control the behavior of this instance.
Definition rendering_api.hpp:5728
UInt8 Mask
A user-defined mask value that is matched with another mask value during ray-tracing to include or di...
Definition rendering_api.hpp:5707
Stores simple memory heap statistics, that can be quickly queried by calling IGraphicsFactory::memory...
Definition rendering_api.hpp:9985
Defines a hint that is used to initialize a dynamic descriptor heap.
Definition rendering_api.hpp:7220
Defines a hint that is used to mark a push constants range.
Definition rendering_api.hpp:7190
Defines a hint that is used to mark additional a binding as used by certain shader stages.
Definition rendering_api.hpp:7244
Defines a hint that is used to bind a static sampler state to a sampler descriptor.
Definition rendering_api.hpp:7201
Defines a hint that is used to mark an unbounded descriptor array.
Definition rendering_api.hpp:7179
A hint used during shader reflection to control the pipeline layout.
Definition rendering_api.hpp:7174
static auto pushConstants(DescriptorBindingPoint at) noexcept -> PipelineBindingHint
Initializes a hint that binds push constants.
Definition rendering_api.hpp:7293
static auto shaderStage(DescriptorBindingPoint at, ShaderStage shaderStages) noexcept -> PipelineBindingHint
Initializes a hint provides additional shader stages, that may be not covered by shader reflection.
Definition rendering_api.hpp:7381
static auto pushConstants(UInt32 space, UInt32 binding) noexcept -> PipelineBindingHint
Initializes a hint that binds push constants.
Definition rendering_api.hpp:7303
static auto staticSampler(UInt32 space, UInt32 binding, SharedPtr< ISampler > sampler) noexcept -> PipelineBindingHint
Initializes a hint that binds a static sampler, if supported by the backend.
Definition rendering_api.hpp:7324
static auto runtimeArray(DescriptorBindingPoint at, UInt32 maxDescriptors) noexcept -> PipelineBindingHint
Initializes a hint that binds an unbounded runtime array.
Definition rendering_api.hpp:7273
Variant< std::monostate, UnboundedArrayHint, PushConstantsHint, StaticSamplerHint, DescriptorHeapHint, ShaderStageHint > hint_type
Defines the type of the pipeline binding hint.
Definition rendering_api.hpp:7254
static auto shaderStage(UInt32 space, UInt32 binding, ShaderStage shaderStages) noexcept -> PipelineBindingHint
Initializes a hint provides additional shader stages, that may be not covered by shader reflection.
Definition rendering_api.hpp:7393
static auto staticSampler(DescriptorBindingPoint at, SharedPtr< ISampler > sampler) noexcept -> PipelineBindingHint
Initializes a hint that binds a static sampler, if supported by the backend.
Definition rendering_api.hpp:7313
static auto samplerHeap(DescriptorBindingPoint at, UInt32 heapSize) noexcept -> PipelineBindingHint
Initializes a hint that binds a proxy descriptor set to access the sampler heap at the provided bindi...
Definition rendering_api.hpp:7358
static auto runtimeArray(UInt32 space, UInt32 binding, UInt32 maxDescriptors) noexcept -> PipelineBindingHint
Initializes a hint that binds an unbounded runtime array.
Definition rendering_api.hpp:7284
static auto resourceHeap(UInt32 space, UInt32 binding, UInt32 heapSize) noexcept -> PipelineBindingHint
Initializes a hint that binds a proxy descriptor set to access the resource heap at the provided bind...
Definition rendering_api.hpp:7347
static auto samplerHeap(UInt32 space, UInt32 binding, UInt32 heapSize) noexcept -> PipelineBindingHint
Initializes a hint that binds a proxy descriptor set to access the sampler heap at the provided bindi...
Definition rendering_api.hpp:7370
static auto resourceHeap(DescriptorBindingPoint at, UInt32 heapSize) noexcept -> PipelineBindingHint
Initializes a hint that binds a proxy descriptor set to access the resource heap at the provided bind...
Definition rendering_api.hpp:7335
Stores information about a buffer resource allocation.
Definition rendering_api.hpp:2419
Stores information about an image resource allocation.
Definition rendering_api.hpp:2463
Contains the parameters for a resource allocation.
Definition rendering_api.hpp:2413
ResourceAllocationInfo(const BufferInfo &bufferInfo, ResourceUsage usage=ResourceUsage::Default, String name="", size_t aliasingOffset=0u)
Creates a new resource allocation info instance for a buffer resource.
Definition rendering_api.hpp:2530
ResourceAllocationInfo(const ImageInfo &imageInfo, ResourceUsage usage=ResourceUsage::Default, String name="", size_t aliasingOffset=0u)
Creates a new resource allocation info instance for an image resource.
Definition rendering_api.hpp:2540
ResourceAllocationInfo(ResourceAllocationInfo &&) noexcept=default
ResourceAllocationInfo()=default
Creates a new resource allocation info instance.
ResourceAllocationInfo(const ResourceAllocationInfo &)=default
Stores the result of a resource allocation.
Definition rendering_api.hpp:2555
ResourceAllocationResult(ResourceAllocationResult &&) noexcept=default
ResourceAllocationResult(SharedPtr< IImage > &&image) noexcept
Initializes an allocation result for an image resource.
Definition rendering_api.hpp:2564
ResourceAllocationResult(const ResourceAllocationResult &)=delete
ResourceAllocationResult(SharedPtr< IBuffer > &&buffer) noexcept
Initializes an allocation result for a buffer resource.
Definition rendering_api.hpp:2571
SharedPtr< TBuffer > buffer() const
Returns the allocated buffer resource, or raises an exception if the allocation does not contain a bu...
Definition rendering_api.hpp:2608
Describes the offsets and sizes of a shader group within a shader binding table buffer.
Definition rendering_api.hpp:4291
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:6800
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:6805
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:6780
constexpr const shader_group_type & shaderGroup() const noexcept override
Returns the shader group containing the modules for this record.
Definition rendering_api.hpp:6795
Denotes a shader record containing no shader-local data.
Definition rendering_api.hpp:6854
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:6876
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:6871
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:6866
IShaderRecord::shader_group_type shader_group_type
Definition rendering_api.hpp:6856
constexpr ShaderRecord(ShaderRecord &&_other) noexcept=default
Takes over another shader record.
Defines a generic shader record.
Definition rendering_api.hpp:6758
Represents an allocation within the memory managed by the virtual allocator.
Definition rendering_api.hpp:3037
An allocator used to allocate the shared object.
Definition containers.hpp:1098
Definition alloc_buffer.cpp:13