LiteFX 0.3.1.2022
Computer Graphics Engine
rendering_api.hpp
1#pragma once
2
3#if !defined (LITEFX_RENDERING_API)
4# if defined(LiteFX_Rendering_EXPORTS) && (defined _WIN32 || defined WINCE)
5# define LITEFX_RENDERING_API __declspec(dllexport)
6# elif (defined(LiteFX_Rendering_EXPORTS) || defined(__APPLE__)) && defined __GNUC__ && __GNUC__ >= 4
7# define LITEFX_RENDERING_API __attribute__ ((visibility ("default")))
8# elif !defined(LiteFX_Rendering_EXPORTS) && (defined _WIN32 || defined WINCE)
9# define LITEFX_RENDERING_API __declspec(dllimport)
10# endif
11#endif
12
13#ifndef LITEFX_RENDERING_API
14# define LITEFX_RENDERING_API
15#endif
16
17#include <litefx/app.hpp>
18#include <litefx/math.hpp>
19#include <litefx/graphics.hpp>
20
21namespace LiteFX::Rendering {
22 using namespace LiteFX;
23 using namespace LiteFX::Math;
24
25 class IGraphicsAdapter;
26 class ISurface;
27 class IShaderModule;
28 class IRenderTarget;
29 class IRasterizer;
30 class IViewport;
31 class IScissor;
32 class IBufferLayout;
33 class IVertexBufferLayout;
34 class IIndexBufferLayout;
35 class IDescriptorLayout;
36 class IMappable;
37 class IDeviceMemory;
38 class IBuffer;
39 class IImage;
40 class ISampler;
41 class IBarrier;
42 class IDescriptorSet;
43 class IDescriptorSetLayout;
44 class IPushConstantsRange;
45 class IPushConstantsLayout;
46 class IShaderProgram;
47 class IPipelineLayout;
48 class IVertexBuffer;
49 class IIndexBuffer;
50 class IInputAssembler;
51 class IPipeline;
52 class ICommandBuffer;
53 class IRenderPipeline;
54 class IComputePipeline;
55 class IFrameBuffer;
56 class IRenderPass;
57 class ISwapChain;
58 class ICommandQueue;
59 class IGraphicsFactory;
60 class IGraphicsDevice;
61 class IRenderBackend;
62
63 // Define enumerations.
67 enum class LITEFX_RENDERING_API GraphicsAdapterType {
71 None = 0x00000000,
72
76 GPU = 0x00000001,
77
81 CPU = 0x00000002,
82
86 Other = 0x7FFFFFFF,
87 };
88
105 enum class LITEFX_RENDERING_API QueueType {
109 None = 0x00000000,
110
114 Graphics = 0x00000001,
115
119 Compute = 0x00000002,
120
124 Transfer = 0x00000004,
125
129 Other = 0x7FFFFFFF
130 };
131
135 enum class LITEFX_RENDERING_API QueuePriority {
139 Normal = 33,
140
144 High = 66,
145
149 Realtime = 100
150 };
151
155 enum class LITEFX_RENDERING_API Format {
156 None = 0x00000000,
157 R4G4_UNORM,
158 R4G4B4A4_UNORM,
159 B4G4R4A4_UNORM,
160 R5G6B5_UNORM,
161 B5G6R5_UNORM,
162 R5G5B5A1_UNORM,
163 B5G5R5A1_UNORM,
164 A1R5G5B5_UNORM,
165 R8_UNORM,
166 R8_SNORM,
167 R8_USCALED,
168 R8_SSCALED,
169 R8_UINT,
170 R8_SINT,
171 R8_SRGB,
172 R8G8_UNORM,
173 R8G8_SNORM,
174 R8G8_USCALED,
175 R8G8_SSCALED,
176 R8G8_UINT,
177 R8G8_SINT,
178 R8G8_SRGB,
179 R8G8B8_UNORM,
180 R8G8B8_SNORM,
181 R8G8B8_USCALED,
182 R8G8B8_SSCALED,
183 R8G8B8_UINT,
184 R8G8B8_SINT,
185 R8G8B8_SRGB,
186 B8G8R8_UNORM,
187 B8G8R8_SNORM,
188 B8G8R8_USCALED,
189 B8G8R8_SSCALED,
190 B8G8R8_UINT,
191 B8G8R8_SINT,
192 B8G8R8_SRGB,
193 R8G8B8A8_UNORM,
194 R8G8B8A8_SNORM,
195 R8G8B8A8_USCALED,
196 R8G8B8A8_SSCALED,
197 R8G8B8A8_UINT,
198 R8G8B8A8_SINT,
199 R8G8B8A8_SRGB,
200 B8G8R8A8_UNORM,
201 B8G8R8A8_SNORM,
202 B8G8R8A8_USCALED,
203 B8G8R8A8_SSCALED,
204 B8G8R8A8_UINT,
205 B8G8R8A8_SINT,
206 B8G8R8A8_SRGB,
207 A8B8G8R8_UNORM,
208 A8B8G8R8_SNORM,
209 A8B8G8R8_USCALED,
210 A8B8G8R8_SSCALED,
211 A8B8G8R8_UINT,
212 A8B8G8R8_SINT,
213 A8B8G8R8_SRGB,
214 A2R10G10B10_UNORM,
215 A2R10G10B10_SNORM,
216 A2R10G10B10_USCALED,
217 A2R10G10B10_SSCALED,
218 A2R10G10B10_UINT,
219 A2R10G10B10_SINT,
220 A2B10G10R10_UNORM,
221 A2B10G10R10_SNORM,
222 A2B10G10R10_USCALED,
223 A2B10G10R10_SSCALED,
224 A2B10G10R10_UINT,
225 A2B10G10R10_SINT,
226 R16_UNORM,
227 R16_SNORM,
228 R16_USCALED,
229 R16_SSCALED,
230 R16_UINT,
231 R16_SINT,
232 R16_SFLOAT,
233 R16G16_UNORM,
234 R16G16_SNORM,
235 R16G16_USCALED,
236 R16G16_SSCALED,
237 R16G16_UINT,
238 R16G16_SINT,
239 R16G16_SFLOAT,
240 R16G16B16_UNORM,
241 R16G16B16_SNORM,
242 R16G16B16_USCALED,
243 R16G16B16_SSCALED,
244 R16G16B16_UINT,
245 R16G16B16_SINT,
246 R16G16B16_SFLOAT,
247 R16G16B16A16_UNORM,
248 R16G16B16A16_SNORM,
249 R16G16B16A16_USCALED,
250 R16G16B16A16_SSCALED,
251 R16G16B16A16_UINT,
252 R16G16B16A16_SINT,
253 R16G16B16A16_SFLOAT,
254 R32_UINT,
255 R32_SINT,
256 R32_SFLOAT,
257 R32G32_UINT,
258 R32G32_SINT,
259 R32G32_SFLOAT,
260 R32G32B32_UINT,
261 R32G32B32_SINT,
262 R32G32B32_SFLOAT,
263 R32G32B32A32_UINT,
264 R32G32B32A32_SINT,
265 R32G32B32A32_SFLOAT,
266 R64_UINT,
267 R64_SINT,
268 R64_SFLOAT,
269 R64G64_UINT,
270 R64G64_SINT,
271 R64G64_SFLOAT,
272 R64G64B64_UINT,
273 R64G64B64_SINT,
274 R64G64B64_SFLOAT,
275 R64G64B64A64_UINT,
276 R64G64B64A64_SINT,
277 R64G64B64A64_SFLOAT,
278 B10G11R11_UFLOAT,
279 E5B9G9R9_UFLOAT,
280 D16_UNORM,
281 X8_D24_UNORM,
282 D32_SFLOAT,
283 S8_UINT,
284 D16_UNORM_S8_UINT,
285 D24_UNORM_S8_UINT,
286 D32_SFLOAT_S8_UINT,
287 BC1_RGB_UNORM,
288 BC1_RGB_SRGB,
289 BC1_RGBA_UNORM,
290 BC1_RGBA_SRGB,
291 BC2_UNORM,
292 BC2_SRGB,
293 BC3_UNORM,
294 BC3_SRGB,
295 BC4_UNORM,
296 BC4_SNORM,
297 BC5_UNORM,
298 BC5_SNORM,
299 BC6H_UFLOAT,
300 BC6H_SFLOAT,
301 BC7_UNORM,
302 BC7_SRGB,
303 Other = 0x7FFFFFFF
304 };
305
312 enum class LITEFX_RENDERING_API BufferFormat {
313 None = 0x00000000,
314 X16F = 0x10000101,
315 X16I = 0x10000201,
316 X16U = 0x10000401,
317 XY16F = 0x10000102,
318 XY16I = 0x10000202,
319 XY16U = 0x10000402,
320 XYZ16F = 0x10000103,
321 XYZ16I = 0x10000203,
322 XYZ16U = 0x10000403,
323 XYZW16F = 0x10000104,
324 XYZW16I = 0x10000204,
325 XYZW16U = 0x10000404,
326 X32F = 0x20000101,
327 X32I = 0x20000201,
328 X32U = 0x20000401,
329 XY32F = 0x20000102,
330 XY32I = 0x20000202,
331 XY32U = 0x20000402,
332 XYZ32F = 0x20000103,
333 XYZ32I = 0x20000203,
334 XYZ32U = 0x20000403,
335 XYZW32F = 0x20000104,
336 XYZW32I = 0x20000204,
337 XYZW32U = 0x20000404
338 };
339
344 enum class LITEFX_RENDERING_API AttributeSemantic {
348 Binormal = 0x00000001,
349
353 BlendIndices = 0x00000002,
354
358 BlendWeight = 0x00000003,
359
363 Color = 0x00000004,
364
368 Normal = 0x00000005,
369
373 Position = 0x00000006,
374
378 TransformedPosition = 0x00000007,
379
383 PointSize = 0x00000008,
384
388 Tangent = 0x00000009,
389
393 TextureCoordinate = 0x0000000A,
394
398 Unknown = 0x7FFFFFFF
399 };
400
409 enum class LITEFX_RENDERING_API DescriptorType {
416 ConstantBuffer = 0x00000001,
417
428 StructuredBuffer = 0x00000002,
429
436 RWStructuredBuffer = 0x00000012,
437
448 Texture = 0x00000003,
449
456 RWTexture = 0x00000013,
457
461 Sampler = 0x00000004,
462
466 InputAttachment = 0x00000005,
467
474 Buffer = 0x00000006,
475
482 RWBuffer = 0x00000016,
483
490 ByteAddressBuffer = 0x00000007,
491
498 RWByteAddressBuffer = 0x00000017,
499 };
500
505 enum class LITEFX_RENDERING_API BufferType {
509 Vertex = 0x00000001,
510
514 Index = 0x00000002,
515
522 Uniform = 0x00000003,
523
530 Storage = 0x00000004,
531
538 Texel = 0x00000005,
539
546 Other = 0x7FFFFFFF
547 };
548
577 enum class LITEFX_RENDERING_API BufferUsage {
586 Staging = 0x00000001,
587
595 Resource = 0x00000002,
596
604 Dynamic = 0x00000010,
605
609 Readback = 0x00000100
610 };
611
615 enum class LITEFX_RENDERING_API IndexType {
619 UInt16 = 0x00000010,
620
624 UInt32 = 0x00000020
625 };
626
630 enum class LITEFX_RENDERING_API ShaderStage {
634 Vertex = 0x00000001,
635
639 TessellationControl = 0x00000002,
640
644 TessellationEvaluation = 0x00000004,
645
652 Geometry = 0x00000008,
653
657 Fragment = 0x00000010,
658
662 Compute = 0x00000020,
663
667 Other = 0x7FFFFFFF
668 };
669
674 enum class LITEFX_RENDERING_API PolygonMode {
678 Solid = 0x00000001,
679
683 Wireframe = 0x00000002,
684
688 Point = 0x00000004
689 };
690
695 enum class LITEFX_RENDERING_API CullMode {
699 FrontFaces = 0x00000001,
700
704 BackFaces = 0x00000002,
705
709 Both = 0x00000004,
710
714 Disabled = 0x0000000F
715 };
716
722 enum class LITEFX_RENDERING_API CullOrder {
726 ClockWise = 0x00000001,
727
731 CounterClockWise = 0x00000002
732 };
733
737 enum class LITEFX_RENDERING_API RenderTargetType {
741 Color = 0x00000001,
742
746 DepthStencil = 0x00000002,
747
754 Present = 0x00000004
755 };
756
761 enum class LITEFX_RENDERING_API ImageDimensions {
765 DIM_1 = 0x01,
766
770 DIM_2 = 0x02,
771
775 DIM_3 = 0x03,
776
780 CUBE = 0x04
781 };
782
786 enum class LITEFX_RENDERING_API MultiSamplingLevel {
790 x1 = 0x00000001,
791
795 x2 = 0x00000002,
796
800 x4 = 0x00000004,
801
805 x8 = 0x00000008,
806
810 x16 = 0x00000010,
811
815 x32 = 0x00000020,
816
820 x64 = 0x00000040
821 };
822
827 enum class LITEFX_RENDERING_API FilterMode {
831 Nearest = 0x00000001,
832
836 Linear = 0x00000002
837 };
838
844 enum class LITEFX_RENDERING_API MipMapMode {
848 Nearest = 0x00000001,
849
853 Linear = 0x00000002
854 };
855
859 enum class LITEFX_RENDERING_API BorderMode {
863 Repeat = 0x00000001,
864
868 RepeatMirrored = 0x00010001,
869
873 ClampToEdge = 0x00000002,
874
878 ClampToEdgeMirrored = 0x00010002,
879
883 ClampToBorder = 0x00000003,
884 };
885
890 enum class LITEFX_RENDERING_API CompareOperation {
894 Never = 0x00000000,
895
899 Less = 0x00000001,
900
904 Greater = 0x0000002,
905
909 Equal = 0x00000003,
910
914 LessEqual = 0x00000004,
915
919 GreaterEqual = 0x00000005,
920
924 NotEqual = 0x00000006,
925
929 Always = 0x00000007
930 };
931
936 enum class LITEFX_RENDERING_API StencilOperation {
940 Keep = 0x00000000,
941
945 Zero = 0x00000001,
946
950 Replace = 0x00000002,
951
955 IncrementClamp = 0x00000003,
956
960 DecrementClamp = 0x00000004,
961
965 Invert = 0x00000005,
966
970 IncrementWrap = 0x00000006,
971
975 DecrementWrap = 0x00000007
976 };
977
982 enum class LITEFX_RENDERING_API BlendFactor {
983 Zero = 0,
984 One = 1,
985 SourceColor = 2,
986 OneMinusSourceColor = 3,
987 DestinationColor = 4,
988 OneMinusDestinationColor = 5,
989 SourceAlpha = 6,
990 OneMinusSourceAlpha = 7,
991 DestinationAlpha = 8,
992 OneMinusDestinationAlpha = 9,
993 ConstantColor = 10,
994 OneMinusConstantColor = 11,
995 ConstantAlpha = 12,
996 OneMinusConstantAlpha = 13,
997 SourceAlphaSaturate = 14,
998 Source1Color = 15,
999 OneMinusSource1Color = 16,
1000 Source1Alpha = 17,
1001 OneMinusSource1Alpha = 18
1002 };
1003
1008 enum class LITEFX_RENDERING_API WriteMask {
1012 R = 0x01,
1013
1017 G = 0x02,
1018
1022 B = 0x04,
1023
1027 A = 0x08
1028 };
1029
1034 enum class LITEFX_RENDERING_API BlendOperation {
1035 Add = 0x01,
1036 Subtract = 0x02,
1037 ReverseSubtract = 0x03,
1038 Minimum = 0x04,
1039 Maximum = 0x05
1040 };
1041
1046 enum class LITEFX_RENDERING_API ResourceState {
1066 Common = 0x00000001,
1067
1087 VertexBuffer = 0x00000002,
1088
1108 IndexBuffer = 0x0000003,
1109
1129 UniformBuffer = 0x00000004,
1130
1150 ReadOnly = 0x00000005,
1151
1173 GenericRead = 0x00000006,
1174
1194 ReadWrite = 0x00000007,
1195
1215 CopySource = 0x00000010,
1216
1236 CopyDestination = 0x00000011,
1237
1259 RenderTarget = 0x00000020,
1260
1282 DepthRead = 0x00000021,
1283
1305 DepthWrite = 0x00000022,
1306
1328 Present = 0x00000023,
1329
1351 ResolveSource = 0x00000024,
1352
1374 ResolveDestination = 0x00000025,
1375
1383 Undefined = 0x7FFFFFFF
1384 };
1385
1386 // Define flags.
1389 LITEFX_DEFINE_FLAGS(BufferFormat);
1391
1392 // Helper functions.
1393
1398 inline UInt32 getBufferFormatChannels(const BufferFormat& format) {
1399 return static_cast<UInt32>(format) & 0x000000FF;
1400 }
1401
1406 inline UInt32 getBufferFormatChannelSize(const BufferFormat& format) {
1407 return (static_cast<UInt32>(format) & 0xFF000000) >> 24;
1408 }
1409
1414 inline UInt32 getBufferFormatType(const BufferFormat& format) {
1415 return (static_cast<UInt32>(format) & 0x0000FF00) >> 8;
1416 }
1417
1421 size_t LITEFX_RENDERING_API getSize(const Format& format);
1422
1427 bool LITEFX_RENDERING_API hasDepth(const Format& format);
1428
1433 bool LITEFX_RENDERING_API hasStencil(const Format& format);
1434
1438 class LITEFX_RENDERING_API IStateResource {
1439 public:
1440 virtual ~IStateResource() noexcept = default;
1441
1442 public:
1447 virtual const String& name() const noexcept = 0;
1448 };
1449
1453 class LITEFX_RENDERING_API StateResource : public virtual IStateResource {
1454 LITEFX_IMPLEMENTATION(StateResourceImpl);
1455
1456 protected:
1457 StateResource() noexcept;
1458
1459 public:
1464 explicit StateResource(StringView name);
1467 virtual ~StateResource() noexcept;
1468
1469 protected:
1471 String& name() noexcept;
1472
1473 public:
1475 virtual const String& name() const noexcept override;
1476 };
1477
1489 class LITEFX_RENDERING_API DeviceState {
1490 LITEFX_IMPLEMENTATION(DeviceStateImpl);
1491 friend class IGraphicsDevice;
1492
1493 public:
1497 explicit DeviceState() noexcept;
1499 DeviceState(const DeviceState&) = delete;
1500 virtual ~DeviceState() noexcept;
1501
1502 public:
1506 void clear();
1507
1513 void add(UniquePtr<IRenderPass>&& renderPass);
1514
1521 void add(const String& id, UniquePtr<IRenderPass>&& renderPass);
1522
1528 void add(UniquePtr<IPipeline>&& pipeline);
1529
1536 void add(const String& id, UniquePtr<IPipeline>&& pipeline);
1537
1543 void add(UniquePtr<IBuffer>&& buffer);
1544
1551 void add(const String& id, UniquePtr<IBuffer>&& buffer);
1552
1558 void add(UniquePtr<IVertexBuffer>&& vertexBuffer);
1559
1566 void add(const String& id, UniquePtr<IVertexBuffer>&& vertexBuffer);
1567
1573 void add(UniquePtr<IIndexBuffer>&& indexBuffer);
1574
1581 void add(const String& id, UniquePtr<IIndexBuffer>&& indexBuffer);
1582
1588 void add(UniquePtr<IImage>&& image);
1589
1596 void add(const String& id, UniquePtr<IImage>&& image);
1597
1603 void add(UniquePtr<ISampler>&& sampler);
1604
1611 void add(const String& id, UniquePtr<ISampler>&& sampler);
1612
1619 void add(const String& id, UniquePtr<IDescriptorSet>&& descriptorSet);
1620
1627 IRenderPass& renderPass(const String& id) const;
1628
1635 IPipeline& pipeline(const String& id) const;
1636
1643 IBuffer& buffer(const String& id) const;
1644
1651 IVertexBuffer& vertexBuffer(const String& id) const;
1652
1659 IIndexBuffer& indexBuffer(const String& id) const;
1660
1667 IImage& image(const String& id) const;
1668
1675 ISampler& sampler(const String& id) const;
1676
1683 IDescriptorSet& descriptorSet(const String& id) const;
1684
1695 bool release(const IRenderPass& renderPass);
1696
1702 bool release(const IPipeline& pipeline);
1703
1709 bool release(const IBuffer& buffer);
1710
1716 bool release(const IVertexBuffer& buffer);
1717
1723 bool release(const IIndexBuffer& buffer);
1724
1730 bool release(const IImage& image);
1731
1737 bool release(const ISampler& sampler);
1738
1744 bool release(const IDescriptorSet& descriptorSet);
1745 };
1746
1754 class LITEFX_RENDERING_API IGraphicsAdapter {
1755 public:
1756 virtual ~IGraphicsAdapter() noexcept = default;
1757
1758 public:
1763 virtual String name() const noexcept = 0;
1764
1769 virtual UInt64 uniqueId() const noexcept = 0;
1770
1775 virtual UInt32 vendorId() const noexcept = 0;
1776
1781 virtual UInt32 deviceId() const noexcept = 0;
1782
1787 virtual GraphicsAdapterType type() const noexcept = 0;
1788
1793 virtual UInt32 driverVersion() const noexcept = 0;
1794
1799 virtual UInt32 apiVersion() const noexcept = 0;
1800
1805 virtual UInt64 dedicatedMemory() const noexcept = 0;
1806 };
1807
1815 class LITEFX_RENDERING_API ISurface {
1816 public:
1817 virtual ~ISurface() noexcept = default;
1818 };
1819
1827 class LITEFX_RENDERING_API IShaderModule {
1828 public:
1829 virtual ~IShaderModule() noexcept = default;
1830
1831 public:
1836 virtual const ShaderStage& type() const noexcept = 0;
1837
1842 virtual const String& fileName() const noexcept = 0;
1843
1848 virtual const String& entryPoint() const noexcept = 0;
1849 };
1850
1862 class LITEFX_RENDERING_API IRenderTarget {
1863 public:
1867 struct BlendState {
1868 public:
1872 bool Enable{ false };
1873
1877 BlendFactor SourceColor{ BlendFactor::One };
1878
1882 BlendFactor DestinationColor{ BlendFactor::Zero };
1883
1887 BlendFactor SourceAlpha{ BlendFactor::One };
1888
1892 BlendFactor DestinationAlpha{ BlendFactor::Zero };
1893
1897 BlendOperation ColorOperation{ BlendOperation::Add };
1898
1902 BlendOperation AlphaOperation{ BlendOperation::Add };
1903
1907 WriteMask WriteMask{ WriteMask::R | WriteMask::G | WriteMask::B | WriteMask::A };
1908 };
1909
1910 public:
1911 virtual ~IRenderTarget() noexcept = default;
1912
1913 public:
1918 virtual const String& name() const noexcept = 0;
1919
1928 virtual const UInt32& location() const noexcept = 0;
1929
1934 virtual const RenderTargetType& type() const noexcept = 0;
1935
1940 virtual const Format& format() const noexcept = 0;
1941
1949 virtual const bool& clearBuffer() const noexcept = 0;
1950
1958 virtual const bool& clearStencil() const noexcept = 0;
1959
1969 virtual const Vector4f& clearValues() const noexcept = 0;
1970
1981 virtual const bool& isVolatile() const noexcept = 0;
1982
1987 virtual const BlendState& blendState() const noexcept = 0;
1988 };
1989
1994 class LITEFX_RENDERING_API RenderTarget : public IRenderTarget {
1995 LITEFX_IMPLEMENTATION(RenderTargetImpl);
1996
1997 public:
1998 RenderTarget() noexcept;
1999
2011 explicit RenderTarget(const UInt32& location, const RenderTargetType& type, const Format& format, const bool& clearBuffer, const Vector4f& clearValues = { 0.f , 0.f, 0.f, 0.f }, const bool& clearStencil = true, const bool& isVolatile = false, const BlendState& blendState = {});
2012
2025 explicit RenderTarget(const String& name, const UInt32& location, const RenderTargetType& type, const Format& format, const bool& clearBuffer, const Vector4f& clearValues = { 0.f , 0.f, 0.f, 0.f }, const bool& clearStencil = true, const bool& isVolatile = false, const BlendState& blendState = {});
2026 RenderTarget(const RenderTarget&) noexcept;
2027 RenderTarget(RenderTarget&&) noexcept;
2028 virtual ~RenderTarget() noexcept;
2029
2030 public:
2031 inline RenderTarget& operator=(const RenderTarget&) noexcept;
2032 inline RenderTarget& operator=(RenderTarget&&) noexcept;
2033
2034 public:
2036 virtual const String& name() const noexcept override;
2037
2039 virtual const UInt32& location() const noexcept override;
2040
2042 virtual const RenderTargetType& type() const noexcept override;
2043
2045 virtual const Format& format() const noexcept override;
2046
2048 virtual const bool& clearBuffer() const noexcept override;
2049
2051 virtual const bool& clearStencil() const noexcept override;
2052
2054 virtual const Vector4f& clearValues() const noexcept override;
2055
2057 virtual const bool& isVolatile() const noexcept override;
2058
2060 virtual const BlendState& blendState() const noexcept override;
2061 };
2062
2066 class LITEFX_RENDERING_API DepthStencilState {
2067 LITEFX_IMPLEMENTATION(DepthStencilStateImpl);
2068
2069 public:
2073 struct DepthState {
2074 public:
2078 bool Enable{ true };
2079
2083 bool Write{ true };
2084
2088 CompareOperation Operation{ CompareOperation::Always };
2089 };
2090
2100 struct DepthBias {
2101 public:
2105 bool Enable{ false };
2106
2110 Float Clamp{ 0.f };
2111
2115 Float SlopeFactor{ 0.f };
2116
2120 Float ConstantFactor{ 0.f };
2121 };
2122
2127 public:
2131 StencilOperation StencilFailOp{ StencilOperation::Keep };
2132
2136 StencilOperation StencilPassOp{ StencilOperation::Replace };
2137
2141 StencilOperation DepthFailOp{ StencilOperation::Keep };
2142
2146 CompareOperation Operation{ CompareOperation::Never };
2147 };
2148
2153 public:
2157 bool Enable{ false };
2158
2162 Byte WriteMask{ 0xFF };
2163
2167 Byte ReadMask{ 0xFF };
2168
2172 StencilTest FrontFace{};
2173
2177 StencilTest BackFace{};
2178 };
2179
2180 public:
2187 explicit DepthStencilState(const DepthState& depthState, const DepthBias& depthBias, const StencilState& stencilState) noexcept;
2188
2192 DepthStencilState() noexcept;
2193
2197 DepthStencilState(const DepthStencilState&) noexcept;
2198
2203
2207 virtual ~DepthStencilState() noexcept;
2208
2213 DepthStencilState& operator=(const DepthStencilState&) noexcept;
2214
2219 DepthStencilState& operator=(DepthStencilState&&) noexcept;
2220
2221 public:
2226 virtual DepthState& depthState() const noexcept;
2227
2232 virtual DepthBias& depthBias() const noexcept;
2233
2238 virtual StencilState& stencilState() const noexcept;
2239 };
2240
2244 class LITEFX_RENDERING_API IRasterizer {
2245 public:
2246 virtual ~IRasterizer() noexcept = default;
2247
2248 public:
2253 virtual const PolygonMode& polygonMode() const noexcept = 0;
2254
2259 virtual const CullMode& cullMode() const noexcept = 0;
2260
2265 virtual const CullOrder& cullOrder() const noexcept = 0;
2266
2275 virtual const Float& lineWidth() const noexcept = 0;
2276
2281 virtual const DepthStencilState& depthStencilState() const noexcept = 0;
2282 };
2283
2287 class LITEFX_RENDERING_API Rasterizer : public IRasterizer {
2288 LITEFX_IMPLEMENTATION(RasterizerImpl);
2289
2290 public:
2299 explicit Rasterizer(const PolygonMode& polygonMode, const CullMode& cullMode, const CullOrder& cullOrder, const Float& lineWidth = 1.f, const DepthStencilState& depthStencilState = {}) noexcept;
2300 Rasterizer(Rasterizer&&) noexcept;
2301 Rasterizer(const Rasterizer&) noexcept;
2302 virtual ~Rasterizer() noexcept;
2303
2304 public:
2306 virtual const PolygonMode& polygonMode() const noexcept override;
2307
2309 virtual const CullMode& cullMode() const noexcept override;
2310
2312 virtual const CullOrder& cullOrder() const noexcept override;
2313
2315 virtual const Float& lineWidth() const noexcept override;
2316
2318 virtual const DepthStencilState& depthStencilState() const noexcept override;
2319
2320 protected:
2321 virtual PolygonMode& polygonMode() noexcept;
2322 virtual CullMode& cullMode() noexcept;
2323 virtual CullOrder& cullOrder() noexcept;
2324 virtual Float& lineWidth() noexcept;
2325 virtual DepthStencilState& depthStencilState() noexcept;
2326 };
2327
2331 class LITEFX_RENDERING_API IViewport {
2332 public:
2333 virtual ~IViewport() noexcept = default;
2334
2335 public:
2340 virtual RectF getRectangle() const noexcept = 0;
2341
2346 virtual void setRectangle(const RectF& rectangle) noexcept = 0;
2347
2352 virtual float getMinDepth() const noexcept = 0;
2353
2358 virtual void setMinDepth(const float& depth) const noexcept = 0;
2359
2364 virtual float getMaxDepth() const noexcept = 0;
2365
2370 virtual void setMaxDepth(const float& depth) const noexcept = 0;
2371 };
2372
2376 class LITEFX_RENDERING_API Viewport : public IViewport {
2377 LITEFX_IMPLEMENTATION(ViewportImpl);
2378
2379 public:
2386 explicit Viewport(const RectF& clientRect = { }, const Float& minDepth = 0.f, const Float& maxDepth = 1.f);
2387
2388 Viewport(Viewport&&) noexcept = delete;
2389 Viewport(const Viewport&) noexcept = delete;
2390 virtual ~Viewport() noexcept;
2391
2392 public:
2394 virtual RectF getRectangle() const noexcept override;
2395
2397 virtual void setRectangle(const RectF& rectangle) noexcept override;
2398
2400 virtual Float getMinDepth() const noexcept override;
2401
2403 virtual void setMinDepth(const Float& depth) const noexcept override;
2404
2406 virtual Float getMaxDepth() const noexcept override;
2407
2409 virtual void setMaxDepth(const Float& depth) const noexcept override;
2410 };
2411
2415 class LITEFX_RENDERING_API IScissor {
2416 public:
2417 virtual ~IScissor() noexcept = default;
2418
2419 public:
2424 virtual RectF getRectangle() const noexcept = 0;
2425
2430 virtual void setRectangle(const RectF& rectangle) noexcept = 0;
2431 };
2432
2436 class LITEFX_RENDERING_API Scissor : public IScissor {
2437 LITEFX_IMPLEMENTATION(ScissorImpl);
2438
2439 public:
2444 explicit Scissor(const RectF& scissorRect = { });
2445
2446 Scissor(Scissor&&) noexcept = delete;
2447 Scissor(const Scissor&) noexcept = delete;
2448 virtual ~Scissor() noexcept;
2449
2450 public:
2452 virtual RectF getRectangle() const noexcept override;
2453
2455 virtual void setRectangle(const RectF& rectangle) noexcept override;
2456 };
2457
2461 class LITEFX_RENDERING_API BufferAttribute {
2462 LITEFX_IMPLEMENTATION(BufferAttributeImpl);
2463
2464 public:
2469
2478 BufferAttribute(const UInt32& location, const UInt32& offset, const BufferFormat& format, const AttributeSemantic& semantic, const UInt32& semanticIndex = 0);
2479 BufferAttribute(BufferAttribute&&) noexcept;
2481 virtual ~BufferAttribute() noexcept;
2482
2483 public:
2491 virtual const UInt32& location() const noexcept;
2492
2497 virtual const BufferFormat& format() const noexcept;
2498
2503 virtual const UInt32& offset() const noexcept;
2504
2513 virtual const AttributeSemantic& semantic() const noexcept;
2514
2523 virtual const UInt32& semanticIndex() const noexcept;
2524 };
2525
2532 class LITEFX_RENDERING_API IBufferLayout {
2533 public:
2534 virtual ~IBufferLayout() noexcept = default;
2535
2536 public:
2541 virtual size_t elementSize() const noexcept = 0;
2542
2550 virtual const UInt32& binding() const noexcept = 0;
2551
2556 virtual const BufferType& type() const noexcept = 0;
2557 };
2558
2563 class LITEFX_RENDERING_API IVertexBufferLayout : public IBufferLayout {
2564 public:
2565 virtual ~IVertexBufferLayout() noexcept = default;
2566
2567 public:
2572 virtual Array<const BufferAttribute*> attributes() const noexcept = 0;
2573 };
2574
2579 class LITEFX_RENDERING_API IIndexBufferLayout : public IBufferLayout {
2580 public:
2581 virtual ~IIndexBufferLayout() noexcept = default;
2582
2583 public:
2588 virtual const IndexType& indexType() const noexcept = 0;
2589 };
2590
2613 class LITEFX_RENDERING_API IDescriptorLayout : public IBufferLayout {
2614 public:
2615 virtual ~IDescriptorLayout() noexcept = default;
2616
2617 public:
2622 virtual const DescriptorType& descriptorType() const noexcept = 0;
2623
2634 virtual const UInt32& descriptors() const noexcept = 0;
2635
2645 virtual const ISampler* staticSampler() const noexcept = 0;
2646 };
2647
2651 class LITEFX_RENDERING_API IMappable {
2652 public:
2653 virtual ~IMappable() noexcept = default;
2654
2655 public:
2662 virtual void map(const void* const data, const size_t& size, const UInt32& element = 0) = 0;
2663
2670 virtual void map(Span<const void* const> data, const size_t& elementSize, const UInt32& firstElement = 0) = 0;
2671 };
2672
2676 class LITEFX_RENDERING_API IDeviceMemory {
2677 public:
2678 virtual ~IDeviceMemory() noexcept = default;
2679
2680 public:
2690 virtual const UInt32& elements() const noexcept = 0;
2691
2705 virtual size_t size() const noexcept = 0;
2706
2716 virtual size_t elementSize() const noexcept = 0;
2717
2724 virtual size_t elementAlignment() const noexcept = 0;
2725
2735 virtual size_t alignedElementSize() const noexcept = 0;
2736
2744 virtual const bool& writable() const noexcept = 0;
2745
2752 virtual const ResourceState& state(const UInt32& subresource = 0) const = 0;
2753
2768 virtual ResourceState& state(const UInt32& subresource = 0) = 0;
2769 };
2770
2774 class LITEFX_RENDERING_API IBuffer : public virtual IDeviceMemory, public virtual IMappable, public virtual IStateResource {
2775 public:
2776 virtual ~IBuffer() noexcept = default;
2777
2778 public:
2783 virtual const BufferType& type() const noexcept = 0;
2784 };
2785
2789 class LITEFX_RENDERING_API IImage : public virtual IDeviceMemory, public virtual IStateResource {
2790 public:
2791 virtual ~IImage() noexcept = default;
2792
2793 public:
2803 virtual size_t size(const UInt32& level) const noexcept = 0;
2804
2814 virtual Size3d extent(const UInt32& level = 0) const noexcept = 0;
2815
2820 virtual const Format& format() const noexcept = 0;
2821
2830 virtual const ImageDimensions& dimensions() const noexcept = 0;
2831
2836 virtual const UInt32& levels() const noexcept = 0;
2837
2842 virtual const UInt32& layers() const noexcept = 0;
2843
2852 virtual const UInt32& planes() const noexcept = 0;
2853
2858 virtual const MultiSamplingLevel& samples() const noexcept = 0;
2859
2860 // TODO: getSampler() for combined samplers?
2861
2862 public:
2863 inline virtual UInt32 subresourceId(const UInt32& level, const UInt32& layer, const UInt32& plane) const noexcept
2864 {
2865 return level + (layer * this->levels()) + (plane * this->levels() * this->layers());
2866 }
2867 };
2868
2872 class LITEFX_RENDERING_API ISampler : public virtual IStateResource {
2873 public:
2874 virtual ~ISampler() noexcept = default;
2875
2876 public:
2881 virtual const FilterMode& getMinifyingFilter() const noexcept = 0;
2882
2887 virtual const FilterMode& getMagnifyingFilter() const noexcept = 0;
2888
2893 virtual const BorderMode& getBorderModeU() const noexcept = 0;
2894
2899 virtual const BorderMode& getBorderModeV() const noexcept = 0;
2900
2905 virtual const BorderMode& getBorderModeW() const noexcept = 0;
2906
2914 virtual const Float& getAnisotropy() const noexcept = 0;
2915
2920 virtual const MipMapMode& getMipMapMode() const noexcept = 0;
2921
2926 virtual const Float& getMipMapBias() const noexcept = 0;
2927
2932 virtual const Float& getMaxLOD() const noexcept = 0;
2933
2938 virtual const Float& getMinLOD() const noexcept = 0;
2939 };
2940
2944 class LITEFX_RENDERING_API IBarrier {
2945 public:
2946 virtual ~IBarrier() noexcept = default;
2947
2948 public:
2954 void transition(IBuffer& buffer, const ResourceState& targetState) {
2955 this->doTransition(buffer, targetState);
2956 };
2957
2964 void transition(IBuffer& buffer, const UInt32& element, const ResourceState& targetState) {
2965 this->doTransition(buffer, element, targetState);
2966 }
2967
2974 void transition(IBuffer& buffer, const ResourceState& sourceState, const ResourceState& targetState) {
2975 this->doTransition(buffer, sourceState, targetState);
2976 }
2977
2986 void transition(IBuffer& buffer, const ResourceState& sourceState, const UInt32& element, const ResourceState& targetState) {
2987 this->doTransition(buffer, sourceState, element, targetState);
2988 }
2989
2995 void transition(IImage& image, const ResourceState& targetState) {
2996 this->doTransition(image, targetState);
2997 }
2998
3007 void transition(IImage& image, const UInt32& level, const UInt32& layer, const UInt32& plane, const ResourceState& targetState) {
3008 this->doTransition(image, level, layer, plane, targetState);
3009 }
3010
3017 void transition(IImage& image, const ResourceState& sourceState, const ResourceState& targetState) {
3018 this->doTransition(image, sourceState, targetState);
3019 }
3020
3030 void transition(IImage& image, const ResourceState& sourceState, const UInt32& level, const UInt32& layer, const UInt32& plane, const ResourceState& targetState) {
3031 this->doTransition(image, sourceState, level, layer, plane, targetState);
3032 }
3033
3041 void waitFor(const IBuffer& buffer) {
3042 this->doWaitFor(buffer);
3043 }
3044
3052 void waitFor(const IImage& image) {
3053 this->doWaitFor(image);
3054 }
3055
3056 private:
3057 virtual void doTransition(IBuffer& buffer, const ResourceState& targetState) = 0;
3058 virtual void doTransition(IBuffer& buffer, const UInt32& element, const ResourceState& targetState) = 0;
3059 virtual void doTransition(IBuffer& buffer, const ResourceState& sourceState, const ResourceState& targetState) = 0;
3060 virtual void doTransition(IBuffer& buffer, const ResourceState& sourceState, const UInt32& element, const ResourceState& targetState) = 0;
3061 virtual void doTransition(IImage& image, const ResourceState& targetState) = 0;
3062 virtual void doTransition(IImage& image, const UInt32& level, const UInt32& layer, const UInt32& plane, const ResourceState& targetState) = 0;
3063 virtual void doTransition(IImage& image, const ResourceState& sourceState, const ResourceState& targetState) = 0;
3064 virtual void doTransition(IImage& image, const ResourceState& sourceState, const UInt32& level, const UInt32& layer, const UInt32& plane, const ResourceState& targetState) = 0;
3065 virtual void doWaitFor(const IBuffer& buffer) = 0;
3066 virtual void doWaitFor(const IImage& image) = 0;
3067 };
3068
3072 class LITEFX_RENDERING_API IDescriptorSet {
3073 public:
3074 virtual ~IDescriptorSet() noexcept = default;
3075
3076 public:
3085 void update(const UInt32& binding, const IBuffer& buffer, const UInt32& bufferElement = 0, const UInt32& elements = 1, const UInt32& firstDescriptor = 0) const {
3086 this->doUpdate(binding, buffer, bufferElement, elements, firstDescriptor);
3087 }
3088
3110 void update(const UInt32& binding, const IImage& texture, const UInt32& descriptor = 0, const UInt32& firstLevel = 0, const UInt32& levels = 0, const UInt32& firstLayer = 0, const UInt32& layers = 0) const {
3111 this->doUpdate(binding, texture, descriptor, firstLevel, levels, firstLayer, layers);
3112 }
3113
3120 void update(const UInt32& binding, const ISampler& sampler, const UInt32& descriptor = 0) const {
3121 this->doUpdate(binding, sampler, descriptor);
3122 }
3123
3129 void attach(const UInt32& binding, const IImage& image) const {
3130 this->doAttach(binding, image);
3131 }
3132
3133 private:
3134 virtual void doUpdate(const UInt32& binding, const IBuffer& buffer, const UInt32& bufferElement, const UInt32& elements, const UInt32& firstDescriptor) const = 0;
3135 virtual void doUpdate(const UInt32& binding, const IImage& texture, const UInt32& descriptor, const UInt32& firstLevel, const UInt32& levels, const UInt32& firstLayer, const UInt32& layers) const = 0;
3136 virtual void doUpdate(const UInt32& binding, const ISampler& sampler, const UInt32& descriptor) const = 0;
3137 virtual void doAttach(const UInt32& binding, const IImage& image) const = 0;
3138 };
3139
3143 class LITEFX_RENDERING_API IDescriptorSetLayout {
3144 public:
3145 virtual ~IDescriptorSetLayout() noexcept = default;
3146
3147 public:
3152 Array<const IDescriptorLayout*> descriptors() const noexcept {
3153 return this->getDescriptors();
3154 }
3155
3161 virtual const IDescriptorLayout& descriptor(const UInt32& binding) const = 0;
3162
3170 virtual const UInt32& space() const noexcept = 0;
3171
3176 virtual const ShaderStage& shaderStages() const noexcept = 0;
3177
3182 virtual UInt32 uniforms() const noexcept = 0;
3183
3188 virtual UInt32 storages() const noexcept = 0;
3189
3194 virtual UInt32 images() const noexcept = 0;
3195
3200 virtual UInt32 buffers() const noexcept = 0;
3201
3207 virtual UInt32 samplers() const noexcept = 0;
3208
3214 virtual UInt32 staticSamplers() const noexcept = 0;
3215
3220 virtual UInt32 inputAttachments() const noexcept = 0;
3221
3222 public:
3249 UniquePtr<IDescriptorSet> allocate(const UInt32& descriptors = 0) const {
3250 return this->getDescriptorSet(descriptors);
3251 }
3252
3260 Array<UniquePtr<IDescriptorSet>> allocateMultiple(const UInt32& descriptorSets, const UInt32& descriptors = 0) const {
3261 return this->getDescriptorSets(descriptorSets, descriptors);
3262 }
3263
3268 void free(const IDescriptorSet& descriptorSet) const noexcept {
3269 this->releaseDescriptorSet(descriptorSet);
3270 }
3271
3272 private:
3273 virtual Array<const IDescriptorLayout*> getDescriptors() const noexcept = 0;
3274 virtual UniquePtr<IDescriptorSet> getDescriptorSet(const UInt32& descriptors) const = 0;
3275 virtual Array<UniquePtr<IDescriptorSet>> getDescriptorSets(const UInt32& descriptorSets, const UInt32& descriptors) const = 0;
3276 virtual void releaseDescriptorSet(const IDescriptorSet& descriptorSet) const noexcept = 0;
3277 };
3278
3282 class LITEFX_RENDERING_API IPushConstantsRange {
3283 public:
3284 virtual ~IPushConstantsRange() noexcept = default;
3285
3286 public:
3291 virtual const UInt32& space() const noexcept = 0;
3292
3297 virtual const UInt32& binding() const noexcept = 0;
3298
3304 virtual const UInt32& offset() const noexcept = 0;
3305
3311 virtual const UInt32& size() const noexcept = 0;
3312
3317 virtual const ShaderStage& stage() const noexcept = 0;
3318 };
3319
3323 class LITEFX_RENDERING_API IPushConstantsLayout {
3324 public:
3325 virtual ~IPushConstantsLayout() noexcept = default;
3326
3327 public:
3332 virtual const UInt32& size() const noexcept = 0;
3333
3342 virtual const IPushConstantsRange& range(const ShaderStage& stage) const = 0;
3343
3349 Array<const IPushConstantsRange*> ranges() const noexcept {
3350 return this->getRanges();
3351 }
3352
3353 private:
3354 virtual Array<const IPushConstantsRange*> getRanges() const noexcept = 0;
3355 };
3356
3361 class LITEFX_RENDERING_API IShaderProgram {
3362 public:
3363 virtual ~IShaderProgram() noexcept = default;
3364
3365 public:
3370 Array<const IShaderModule*> modules() const noexcept {
3371 return this->getModules();
3372 }
3373
3399 return this->parsePipelineLayout();
3400 };
3401
3402 private:
3403 virtual Array<const IShaderModule*> getModules() const noexcept = 0;
3404 virtual SharedPtr<IPipelineLayout> parsePipelineLayout() const = 0;
3405 };
3406
3410 class LITEFX_RENDERING_API IPipelineLayout {
3411 public:
3412 virtual ~IPipelineLayout() noexcept = default;
3413
3414 public:
3420 virtual const IDescriptorSetLayout& descriptorSet(const UInt32& space) const = 0;
3421
3426 Array<const IDescriptorSetLayout*> descriptorSets() const noexcept {
3427 return this->getDescriptorSets();
3428 }
3429
3434 virtual const IPushConstantsLayout* pushConstants() const noexcept = 0;
3435
3436 private:
3437 virtual Array<const IDescriptorSetLayout*> getDescriptorSets() const noexcept = 0;
3438 };
3439
3443 class LITEFX_RENDERING_API IVertexBuffer : public virtual IBuffer {
3444 public:
3445 virtual ~IVertexBuffer() noexcept = default;
3446
3447 public:
3452 virtual const IVertexBufferLayout& layout() const noexcept = 0;
3453 };
3454
3458 class LITEFX_RENDERING_API IIndexBuffer : public virtual IBuffer {
3459 public:
3460 virtual ~IIndexBuffer() noexcept = default;
3461
3462 public:
3467 virtual const IIndexBufferLayout& layout() const noexcept = 0;
3468 };
3469
3473 class LITEFX_RENDERING_API IInputAssembler {
3474 public:
3475 virtual ~IInputAssembler() noexcept = default;
3476
3477 public:
3482 Array<const IVertexBufferLayout*> vertexBufferLayouts() const noexcept {
3483 return this->getVertexBufferLayouts();
3484 }
3485
3491 virtual const IVertexBufferLayout& vertexBufferLayout(const UInt32& binding) const = 0;
3492
3497 virtual const IIndexBufferLayout& indexBufferLayout() const = 0;
3498
3503 virtual const PrimitiveTopology& topology() const noexcept = 0;
3504
3505 private:
3506 virtual Array<const IVertexBufferLayout*> getVertexBufferLayouts() const noexcept = 0;
3507 };
3508
3512 class LITEFX_RENDERING_API IPipeline : public virtual IStateResource {
3513 public:
3514 virtual ~IPipeline() noexcept = default;
3515
3516 public:
3521 SharedPtr<const IShaderProgram> program() const noexcept {
3522 return this->getProgram();
3523 }
3524
3530 return this->getLayout();
3531 }
3532
3533 private:
3534 virtual SharedPtr<const IShaderProgram> getProgram() const noexcept = 0;
3535 virtual SharedPtr<const IPipelineLayout> getLayout() const noexcept = 0;
3536 };
3537
3541 class LITEFX_RENDERING_API ICommandBuffer {
3542 public:
3543 virtual ~ICommandBuffer() noexcept = default;
3544
3545 public:
3554 virtual void begin() const = 0;
3555
3563 virtual void end() const = 0;
3564
3565 public:
3576 void barrier(const IBarrier& barrier, const bool& invert = false) const noexcept {
3577 this->cmdBarrier(barrier, invert);
3578 }
3579
3593 void generateMipMaps(IImage& image) noexcept {
3594 this->cmdGenerateMipMaps(image);
3595 }
3596
3606 void transfer(const IBuffer& source, const IBuffer& target, const UInt32& sourceElement = 0, const UInt32& targetElement = 0, const UInt32& elements = 1) const {
3607 this->cmdTransfer(source, target, sourceElement, targetElement, elements);
3608 }
3609
3642 void transfer(const IBuffer& source, const IImage& target, const UInt32& sourceElement = 0, const UInt32& firstSubresource = 0, const UInt32& elements = 1) const {
3643 this->cmdTransfer(source, target, sourceElement, firstSubresource, elements);
3644 }
3645
3655 void transfer(const IImage& source, const IImage& target, const UInt32& sourceSubresource = 0, const UInt32& targetSubresource = 0, const UInt32& subresources = 1) const {
3656 this->cmdTransfer(source, target, sourceSubresource, targetSubresource, subresources);
3657 }
3658
3691 void transfer(const IImage& source, const IBuffer& target, const UInt32& firstSubresource = 0, const UInt32& targetElement = 0, const UInt32& subresources = 1) const {
3692 this->cmdTransfer(source, target, firstSubresource, targetElement, subresources);
3693 }
3694
3698 void use(const IPipeline& pipeline) const noexcept {
3699 this->cmdUse(pipeline);
3700 }
3701
3702 // TODO: Allow bind to last used pipeline (throw, if no pipeline is in use.
3703 //void bind(const IDescriptorSet& descriptorSet) const;
3704
3710 void bind(const IDescriptorSet& descriptorSet, const IPipeline& pipeline) const noexcept {
3711 this->cmdBind(descriptorSet, pipeline);
3712 }
3713
3724 void bind(const IVertexBuffer& buffer) const noexcept {
3725 this->cmdBind(buffer);
3726 }
3727
3737 void bind(const IIndexBuffer& buffer) const noexcept {
3738 this->cmdBind(buffer);
3739 }
3740
3745 virtual void dispatch(const Vector3u& threadCount) const noexcept = 0;
3746
3754 virtual void draw(const UInt32& vertices, const UInt32& instances = 1, const UInt32& firstVertex = 0, const UInt32& firstInstance = 0) const noexcept = 0;
3755
3764 virtual void drawIndexed(const UInt32& indices, const UInt32& instances = 1, const UInt32& firstIndex = 0, const Int32& vertexOffset = 0, const UInt32& firstInstance = 0) const noexcept = 0;
3765
3771 void pushConstants(const IPushConstantsLayout& layout, const void* const memory) const noexcept {
3772 this->cmdPushConstants(layout, memory);
3773 }
3774
3785 void draw(const IVertexBuffer& vertexBuffer, const UInt32& instances = 1, const UInt32& firstVertex = 0, const UInt32& firstInstance = 0) const {
3786 this->cmdDraw(vertexBuffer, instances, firstVertex, firstInstance);
3787 }
3788
3800 void drawIndexed(const IIndexBuffer& indexBuffer, const UInt32& instances = 1, const UInt32& firstIndex = 0, const Int32& vertexOffset = 0, const UInt32& firstInstance = 0) const {
3801 this->cmdDrawIndexed(indexBuffer, instances, firstIndex, vertexOffset, firstInstance);
3802 }
3803
3816 void drawIndexed(const IVertexBuffer& vertexBuffer, const IIndexBuffer& indexBuffer, const UInt32& instances = 1, const UInt32& firstIndex = 0, const Int32& vertexOffset = 0, const UInt32& firstInstance = 0) const {
3817 this->cmdDrawIndexed(vertexBuffer, indexBuffer, instances, firstIndex, vertexOffset, firstInstance);
3818 }
3819
3820 private:
3821 virtual void cmdBarrier(const IBarrier& barrier, const bool& invert) const noexcept = 0;
3822 virtual void cmdGenerateMipMaps(IImage& image) noexcept = 0;
3823 virtual void cmdTransfer(const IBuffer& source, const IBuffer& target, const UInt32& sourceElement, const UInt32& targetElement, const UInt32& elements) const = 0;
3824 virtual void cmdTransfer(const IBuffer& source, const IImage& target, const UInt32& sourceElement, const UInt32& firstSubresource, const UInt32& elements) const = 0;
3825 virtual void cmdTransfer(const IImage& source, const IImage& target, const UInt32& sourceSubresource, const UInt32& targetSubresource, const UInt32& subresources) const = 0;
3826 virtual void cmdTransfer(const IImage& source, const IBuffer& target, const UInt32& firstSubresource, const UInt32& targetElement, const UInt32& subresources) const = 0;
3827 virtual void cmdUse(const IPipeline& pipeline) const noexcept = 0;
3828 virtual void cmdBind(const IDescriptorSet& descriptorSet, const IPipeline& pipeline) const noexcept = 0;
3829 virtual void cmdBind(const IVertexBuffer& buffer) const noexcept = 0;
3830 virtual void cmdBind(const IIndexBuffer& buffer) const noexcept = 0;
3831 virtual void cmdPushConstants(const IPushConstantsLayout& layout, const void* const memory) const noexcept = 0;
3832 virtual void cmdDraw(const IVertexBuffer& vertexBuffer, const UInt32& instances, const UInt32& firstVertex, const UInt32& firstInstance) const = 0;
3833 virtual void cmdDrawIndexed(const IIndexBuffer& indexBuffer, const UInt32& instances, const UInt32& firstIndex, const Int32& vertexOffset, const UInt32& firstInstance) const = 0;
3834 virtual void cmdDrawIndexed(const IVertexBuffer& vertexBuffer, const IIndexBuffer& indexBuffer, const UInt32& instances, const UInt32& firstIndex, const Int32& vertexOffset, const UInt32& firstInstance) const = 0;
3835 };
3836
3840 class LITEFX_RENDERING_API IRenderPipeline : public virtual IPipeline {
3841 public:
3842 virtual ~IRenderPipeline() noexcept = default;
3843
3844 public:
3849 SharedPtr<IInputAssembler> inputAssembler() const noexcept {
3850 return this->getInputAssembler();
3851 }
3852
3858 return this->getRasterizer();
3859 }
3860
3865 virtual Array<const IViewport*> viewports() const noexcept = 0;
3866
3871 virtual Array<const IScissor*> scissors() const noexcept = 0;
3872
3880 virtual UInt32& stencilRef() const noexcept = 0;
3881
3891 virtual Vector4f& blendFactors() const noexcept = 0;
3892
3906 virtual const bool& alphaToCoverage() const noexcept = 0;
3907
3908 private:
3909 virtual SharedPtr<IInputAssembler> getInputAssembler() const noexcept = 0;
3910 virtual SharedPtr<IRasterizer> getRasterizer() const noexcept = 0;
3911 };
3912
3916 class LITEFX_RENDERING_API IComputePipeline : public virtual IPipeline {
3917 public:
3918 virtual ~IComputePipeline() noexcept = default;
3919 };
3920
3924 class LITEFX_RENDERING_API IFrameBuffer {
3925 public:
3926 virtual ~IFrameBuffer() noexcept = default;
3927
3928 public:
3937 virtual const UInt32& bufferIndex() const noexcept = 0;
3938
3946 virtual const Size2d& size() const noexcept = 0;
3947
3955 virtual size_t getWidth() const noexcept = 0;
3956
3964 virtual size_t getHeight() const noexcept = 0;
3965
3971 Array<const ICommandBuffer*> commandBuffers() const noexcept {
3972 return this->getCommandBuffers();
3973 }
3974
3982 virtual const ICommandBuffer& commandBuffer(const UInt32& index) const = 0;
3983
3988 Array<const IImage*> images() const noexcept {
3989 return this->getImages();
3990 }
3991
3996 virtual const IImage& image(const UInt32& location) const = 0;
3997
3998 public:
4009 virtual void resize(const Size2d& renderArea) = 0;
4010
4011 private:
4012 virtual Array<const ICommandBuffer*> getCommandBuffers() const noexcept = 0;
4013 virtual Array<const IImage*> getImages() const noexcept = 0;
4014 };
4015
4019 class LITEFX_RENDERING_API IRenderPass : public virtual IStateResource {
4020 public:
4021 virtual ~IRenderPass() noexcept = default;
4022
4023 public:
4033 virtual const IFrameBuffer& activeFrameBuffer() const = 0;
4034
4039 Array<const IFrameBuffer*> frameBuffers() const noexcept {
4040 return this->getFrameBuffers();
4041 }
4042
4049 return this->getPipelines();
4050 }
4051
4057 virtual const RenderTarget& renderTarget(const UInt32& location) const = 0;
4058
4068 virtual Span<const RenderTarget> renderTargets() const noexcept = 0;
4069
4075 virtual bool hasPresentTarget() const noexcept = 0;
4076
4081 //virtual Span<const IInputAttachmentMapping> inputAttachments() const noexcept = 0;
4082
4087 virtual const MultiSamplingLevel& multiSamplingLevel() const noexcept = 0;
4088
4089 public:
4094 virtual void begin(const UInt32& buffer) = 0;
4095
4103 virtual void end() const = 0;
4104
4109 virtual void resizeFrameBuffers(const Size2d& renderArea) = 0;
4110
4121 virtual void changeMultiSamplingLevel(const MultiSamplingLevel& samples) = 0;
4122
4127 void updateAttachments(const IDescriptorSet& descriptorSet) const {
4128 this->setAttachments(descriptorSet);
4129 }
4130
4131 private:
4132 virtual Array<const IFrameBuffer*> getFrameBuffers() const noexcept = 0;
4133 virtual Array<const IRenderPipeline*> getPipelines() const noexcept = 0;
4134 virtual void setAttachments(const IDescriptorSet& descriptorSet) const = 0;
4135 };
4136
4140 class LITEFX_RENDERING_API ISwapChain {
4141 public:
4142 virtual ~ISwapChain() noexcept = default;
4143
4144 public:
4149 virtual const Format& surfaceFormat() const noexcept = 0;
4150
4155 virtual const UInt32& buffers() const noexcept = 0;
4156
4161 virtual const Size2d& renderArea() const noexcept = 0;
4162
4167 Array<const IImage*> images() const noexcept {
4168 return this->getImages();
4169 };
4170
4175 virtual void present(const IFrameBuffer& frameBuffer) const = 0;
4176
4177 public:
4184 virtual Array<Format> getSurfaceFormats() const noexcept = 0;
4185
4200 virtual void reset(const Format& surfaceFormat, const Size2d& renderArea, const UInt32& buffers) = 0;
4201
4206 [[nodiscard]] virtual UInt32 swapBackBuffer() const = 0;
4207
4208 private:
4209 virtual Array<const IImage*> getImages() const noexcept = 0;
4210 };
4211
4215 class LITEFX_RENDERING_API ICommandQueue {
4216 public:
4217 virtual ~ICommandQueue() noexcept = default;
4218
4219 public:
4230 virtual bool isBound() const noexcept = 0;
4231
4236 virtual const QueuePriority& priority() const noexcept = 0;
4237
4242 virtual const QueueType& type() const noexcept = 0;
4243
4244 public:
4249 virtual void bind() = 0;
4250
4254 virtual void release() = 0;
4255
4261 UniquePtr<ICommandBuffer> createCommandBuffer(const bool& beginRecording = false) const {
4262 return this->getCommandBuffer(beginRecording);
4263 }
4264
4274 UInt64 submit(const ICommandBuffer& commandBuffer) const {
4275 return this->submitCommandBuffer(commandBuffer);
4276 }
4277
4287 UInt64 submit(const Array<const ICommandBuffer*>& commandBuffers) const {
4288 return this->submitCommandBuffers(commandBuffers);
4289 }
4290
4306 virtual void waitFor(const UInt64& fence) const noexcept = 0;
4307
4313 virtual UInt64 currentFence() const noexcept = 0;
4314
4315 private:
4316 virtual UniquePtr<ICommandBuffer> getCommandBuffer(const bool& beginRecording) const = 0;
4317 virtual UInt64 submitCommandBuffer(const ICommandBuffer& commandBuffer) const = 0;
4318 virtual UInt64 submitCommandBuffers(const Array<const ICommandBuffer*>& commandBuffers) const = 0;
4319 };
4320
4324 class LITEFX_RENDERING_API IGraphicsFactory {
4325 public:
4326 virtual ~IGraphicsFactory() noexcept = default;
4327
4328 public:
4338 UniquePtr<IBuffer> createBuffer(const BufferType& type, const BufferUsage& usage, const size_t& elementSize, const UInt32& elements = 1, const bool& allowWrite = false) const {
4339 return this->getBuffer(type, usage, elementSize, elements, allowWrite);
4340 };
4341
4352 UniquePtr<IBuffer> createBuffer(const String& name, const BufferType& type, const BufferUsage& usage, const size_t& elementSize, const UInt32& elements = 1, const bool& allowWrite = false) const {
4353 return this->getBuffer(name, type, usage, elementSize, elements, allowWrite);
4354 };
4355
4368 UniquePtr<IVertexBuffer> createVertexBuffer(const IVertexBufferLayout& layout, const BufferUsage& usage, const UInt32& elements = 1) const {
4369 return this->getVertexBuffer(layout, usage, elements);
4370 }
4371
4385 UniquePtr<IVertexBuffer> createVertexBuffer(const String& name, const IVertexBufferLayout& layout, const BufferUsage& usage, const UInt32& elements = 1) const {
4386 return this->getVertexBuffer(name, layout, usage, elements);
4387 }
4388
4401 UniquePtr<IIndexBuffer> createIndexBuffer(const IIndexBufferLayout& layout, const BufferUsage& usage, const UInt32& elements) const {
4402 return this->getIndexBuffer(layout, usage, elements);
4403 }
4404
4418 UniquePtr<IIndexBuffer> createIndexBuffer(const String& name, const IIndexBufferLayout& layout, const BufferUsage& usage, const UInt32& elements) const {
4419 return this->getIndexBuffer(name, layout, usage, elements);
4420 }
4421
4429 UniquePtr<IImage> createAttachment(const Format& format, const Size2d& size, const MultiSamplingLevel& samples = MultiSamplingLevel::x1) const {
4430 return this->getAttachment(format, size, samples);
4431 }
4432
4441 UniquePtr<IImage> createAttachment(const String& name, const Format& format, const Size2d& size, const MultiSamplingLevel& samples = MultiSamplingLevel::x1) const {
4442 return this->getAttachment(name, format, size, samples);
4443 }
4444
4461 UniquePtr<IImage> createTexture(const Format& format, const Size3d& size, const ImageDimensions& dimension = ImageDimensions::DIM_2, const UInt32& levels = 1, const UInt32& layers = 1, const MultiSamplingLevel& samples = MultiSamplingLevel::x1, const bool& allowWrite = false) const {
4462 return this->getTexture(format, size, dimension, levels, layers, samples, allowWrite);
4463 }
4464
4482 UniquePtr<IImage> createTexture(const String& name, const Format& format, const Size3d& size, const ImageDimensions& dimension = ImageDimensions::DIM_2, const UInt32& levels = 1, const UInt32& layers = 1, const MultiSamplingLevel& samples = MultiSamplingLevel::x1, const bool& allowWrite = false) const {
4483 return this->getTexture(name, format, size, dimension, levels, layers, samples, allowWrite);
4484 }
4485
4499 Array<UniquePtr<IImage>> createTextures(const UInt32& elements, const Format& format, const Size3d& size, const ImageDimensions& dimension = ImageDimensions::DIM_2, const UInt32& layers = 1, const UInt32& levels = 1, const MultiSamplingLevel& samples = MultiSamplingLevel::x1, const bool& allowWrite = false) const {
4500 return this->getTextures(elements, format, size, dimension, layers, levels, samples, allowWrite);
4501 }
4502
4518 UniquePtr<ISampler> createSampler(const FilterMode& magFilter = FilterMode::Nearest, const FilterMode& minFilter = FilterMode::Nearest, const BorderMode& borderU = BorderMode::Repeat, const BorderMode& borderV = BorderMode::Repeat, const BorderMode& borderW = BorderMode::Repeat, const MipMapMode& mipMapMode = MipMapMode::Nearest, const Float& mipMapBias = 0.f, const Float& maxLod = std::numeric_limits<Float>::max(), const Float& minLod = 0.f, const Float& anisotropy = 0.f) const {
4519 return this->getSampler(magFilter, minFilter, borderU, borderV, borderW, mipMapMode, mipMapBias, maxLod, minLod, anisotropy);
4520 }
4521
4538 UniquePtr<ISampler> createSampler(const String& name, const FilterMode& magFilter = FilterMode::Nearest, const FilterMode& minFilter = FilterMode::Nearest, const BorderMode& borderU = BorderMode::Repeat, const BorderMode& borderV = BorderMode::Repeat, const BorderMode& borderW = BorderMode::Repeat, const MipMapMode& mipMapMode = MipMapMode::Nearest, const Float& mipMapBias = 0.f, const Float& maxLod = std::numeric_limits<Float>::max(), const Float& minLod = 0.f, const Float& anisotropy = 0.f) const {
4539 return this->getSampler(name, magFilter, minFilter, borderU, borderV, borderW, mipMapMode, mipMapBias, maxLod, minLod, anisotropy);
4540 }
4541
4558 Array<UniquePtr<ISampler>> createSamplers(const UInt32& elements, const FilterMode& magFilter = FilterMode::Nearest, const FilterMode& minFilter = FilterMode::Nearest, const BorderMode& borderU = BorderMode::Repeat, const BorderMode& borderV = BorderMode::Repeat, const BorderMode& borderW = BorderMode::Repeat, const MipMapMode& mipMapMode = MipMapMode::Nearest, const Float& mipMapBias = 0.f, const Float& maxLod = std::numeric_limits<Float>::max(), const Float& minLod = 0.f, const Float& anisotropy = 0.f) const {
4559 return this->getSamplers(elements, magFilter, minFilter, borderU, borderV, borderW, mipMapMode, mipMapBias, maxLod, minLod, anisotropy);
4560 }
4561
4562 private:
4563 virtual UniquePtr<IBuffer> getBuffer(const BufferType& type, const BufferUsage& usage, const size_t& elementSize, const UInt32& elements, const bool& allowWrite) const = 0;
4564 virtual UniquePtr<IBuffer> getBuffer(const String& name, const BufferType& type, const BufferUsage& usage, const size_t& elementSize, const UInt32& elements, const bool& allowWrite) const = 0;
4565 virtual UniquePtr<IVertexBuffer> getVertexBuffer(const IVertexBufferLayout& layout, const BufferUsage& usage, const UInt32& elements) const = 0;
4566 virtual UniquePtr<IVertexBuffer> getVertexBuffer(const String& name, const IVertexBufferLayout& layout, const BufferUsage& usage, const UInt32& elements) const = 0;
4567 virtual UniquePtr<IIndexBuffer> getIndexBuffer(const IIndexBufferLayout& layout, const BufferUsage& usage, const UInt32& elements) const = 0;
4568 virtual UniquePtr<IIndexBuffer> getIndexBuffer(const String& name, const IIndexBufferLayout& layout, const BufferUsage& usage, const UInt32& elements) const = 0;
4569 virtual UniquePtr<IImage> getAttachment(const Format& format, const Size2d& size, const MultiSamplingLevel& samples) const = 0;
4570 virtual UniquePtr<IImage> getAttachment(const String& name, const Format& format, const Size2d& size, const MultiSamplingLevel& samples) const = 0;
4571 virtual UniquePtr<IImage> getTexture(const Format& format, const Size3d& size, const ImageDimensions& dimension, const UInt32& levels, const UInt32& layers, const MultiSamplingLevel& samples, const bool& allowWrite) const = 0;
4572 virtual UniquePtr<IImage> getTexture(const String& name, const Format& format, const Size3d& size, const ImageDimensions& dimension, const UInt32& levels, const UInt32& layers, const MultiSamplingLevel& samples, const bool& allowWrite) const = 0;
4573 virtual Array<UniquePtr<IImage>> getTextures(const UInt32& elements, const Format& format, const Size3d& size, const ImageDimensions& dimension, const UInt32& layers, const UInt32& levels, const MultiSamplingLevel& samples, const bool& allowWrite) const = 0;
4574 virtual UniquePtr<ISampler> getSampler(const FilterMode& magFilter, const FilterMode& minFilter, const BorderMode& borderU, const BorderMode& borderV, const BorderMode& borderW, const MipMapMode& mipMapMode, const Float& mipMapBias, const Float& maxLod, const Float& minLod, const Float& anisotropy) const = 0;
4575 virtual UniquePtr<ISampler> getSampler(const String& name, const FilterMode& magFilter, const FilterMode& minFilter, const BorderMode& borderU, const BorderMode& borderV, const BorderMode& borderW, const MipMapMode& mipMapMode, const Float& mipMapBias, const Float& maxLod, const Float& minLod, const Float& anisotropy) const = 0;
4576 virtual Array<UniquePtr<ISampler>> getSamplers(const UInt32& elements, const FilterMode& magFilter, const FilterMode& minFilter, const BorderMode& borderU, const BorderMode& borderV, const BorderMode& borderW, const MipMapMode& mipMapMode, const Float& mipMapBias, const Float& maxLod, const Float& minLod, const Float& anisotropy) const = 0;
4577 };
4578
4582 class LITEFX_RENDERING_API IGraphicsDevice {
4583 public:
4584 virtual ~IGraphicsDevice() noexcept = default;
4585
4586 public:
4591 virtual DeviceState& state() const noexcept = 0;
4592
4597 virtual const ISurface& surface() const noexcept = 0;
4598
4603 virtual const IGraphicsAdapter& adapter() const noexcept = 0;
4604
4609 virtual const ISwapChain& swapChain() const noexcept = 0;
4610
4615 virtual ISwapChain& swapChain() noexcept = 0;
4616
4621 virtual const IGraphicsFactory& factory() const noexcept = 0;
4622
4627 virtual const ICommandQueue& graphicsQueue() const noexcept = 0;
4628
4636 virtual const ICommandQueue& transferQueue() const noexcept = 0;
4637
4645 virtual const ICommandQueue& bufferQueue() const noexcept = 0;
4646
4654 virtual const ICommandQueue& computeQueue() const noexcept = 0;
4655
4660 UniquePtr<IBarrier> makeBarrier() const noexcept {
4661 return this->getNewBarrier();
4662 }
4663
4673 virtual MultiSamplingLevel maximumMultiSamplingLevel(const Format& format) const noexcept = 0;
4674
4675 public:
4683 virtual void wait() const = 0;
4684
4685 private:
4686 virtual UniquePtr<IBarrier> getNewBarrier() const noexcept = 0;
4687 };
4688
4692 class LITEFX_RENDERING_API IRenderBackend : public IBackend {
4693 public:
4694 virtual ~IRenderBackend() noexcept = default;
4695
4696 public:
4701 Array<const IGraphicsAdapter*> listAdapters() const {
4702 return this->getAdapters();
4703 }
4704
4716 virtual const IGraphicsAdapter* findAdapter(const Optional<UInt64>& adapterId = std::nullopt) const = 0;
4717
4723 virtual IGraphicsDevice* device(const String& name) noexcept = 0;
4724
4730 virtual const IGraphicsDevice* device(const String& name) const noexcept = 0;
4731
4737 virtual const IGraphicsDevice* operator[](const String& name) const noexcept {
4738 return this->device(name);
4739 };
4740
4746 virtual IGraphicsDevice* operator[](const String& name) noexcept {
4747 return this->device(name);
4748 };
4749
4750 private:
4751 virtual Array<const IGraphicsAdapter*> getAdapters() const = 0;
4752 };
4753}
The base class for an app backend.
Definition: app.hpp:18
Definition: math.hpp:647
Definition: math.hpp:571
Definition: math.hpp:540
Definition: math.hpp:271
Definition: math.hpp:349
Stores meta data about a buffer attribute, i.e. a member or field of a descriptor or buffer.
Definition: rendering_api.hpp:2461
virtual ~BufferAttribute() noexcept
Stores the depth/stencil state of a see IRasterizer.
Definition: rendering_api.hpp:2066
A class that can be used to manage the state of a IGraphicsDevice.
Definition: rendering_api.hpp:1489
The interface for a memory barrier.
Definition: rendering_api.hpp:2944
void transition(IImage &image, const ResourceState &sourceState, const ResourceState &targetState)
Inserts a transition for all sub-resources of image from sourceState into targetState .
Definition: rendering_api.hpp:3017
void transition(IBuffer &buffer, const ResourceState &sourceState, const UInt32 &element, const ResourceState &targetState)
Inserts a transition for the sub-resource element of buffer from sourceState into targetState .
Definition: rendering_api.hpp:2986
void transition(IImage &image, const UInt32 &level, const UInt32 &layer, const UInt32 &plane, const ResourceState &targetState)
Inserts a transition for a sub-resource of image into targetState .
Definition: rendering_api.hpp:3007
void transition(IImage &image, const ResourceState &targetState)
Inserts a transition for all sub-resources of image into targetState .
Definition: rendering_api.hpp:2995
void waitFor(const IImage &image)
Inserts a barrier that waits for all read/write accesses to image to be finished before continuing.
Definition: rendering_api.hpp:3052
virtual ~IBarrier() noexcept=default
void transition(IBuffer &buffer, const ResourceState &sourceState, const ResourceState &targetState)
Inserts a transition for all sub-resources of buffer from sourceState into targetState .
Definition: rendering_api.hpp:2974
void transition(IImage &image, const ResourceState &sourceState, const UInt32 &level, const UInt32 &layer, const UInt32 &plane, const ResourceState &targetState)
Inserts a transition for a sub-resource of image from sourceState into targetState .
Definition: rendering_api.hpp:3030
void waitFor(const IBuffer &buffer)
Inserts a barrier that waits for all read/write accesses to buffer to be finished before continuing.
Definition: rendering_api.hpp:3041
void transition(IBuffer &buffer, const UInt32 &element, const ResourceState &targetState)
Inserts a transition for the sub-resource element of buffer into targetState .
Definition: rendering_api.hpp:2964
Base interface for buffer objects.
Definition: rendering_api.hpp:2774
virtual ~IBuffer() noexcept=default
Describes a buffer layout.
Definition: rendering_api.hpp:2532
virtual ~IBufferLayout() noexcept=default
The interface for a command buffer.
Definition: rendering_api.hpp:3541
void transfer(const IImage &source, const IBuffer &target, const UInt32 &firstSubresource=0, const UInt32 &targetElement=0, const UInt32 &subresources=1) const
Performs an image-to-buffer transfer from source to target .
Definition: rendering_api.hpp:3691
void bind(const IDescriptorSet &descriptorSet, const IPipeline &pipeline) const noexcept
Binds the provided descriptor set to the provided pipeline.
Definition: rendering_api.hpp:3710
void drawIndexed(const IIndexBuffer &indexBuffer, const UInt32 &instances=1, const UInt32 &firstIndex=0, const Int32 &vertexOffset=0, const UInt32 &firstInstance=0) const
Draws the currently bound vertex buffer using the index buffer provided in indexBuffer .
Definition: rendering_api.hpp:3800
void transfer(const IImage &source, const IImage &target, const UInt32 &sourceSubresource=0, const UInt32 &targetSubresource=0, const UInt32 &subresources=1) const
Performs an image-to-image transfer from source to target .
Definition: rendering_api.hpp:3655
void draw(const IVertexBuffer &vertexBuffer, const UInt32 &instances=1, const UInt32 &firstVertex=0, const UInt32 &firstInstance=0) const
Draws all vertices from the vertex buffer provided in vertexBuffer .
Definition: rendering_api.hpp:3785
void drawIndexed(const IVertexBuffer &vertexBuffer, const IIndexBuffer &indexBuffer, const UInt32 &instances=1, const UInt32 &firstIndex=0, const Int32 &vertexOffset=0, const UInt32 &firstInstance=0) const
Draws the vertex buffer provided by vertexBuffer using the index buffer, provided by indexBuffer .
Definition: rendering_api.hpp:3816
void transfer(const IBuffer &source, const IBuffer &target, const UInt32 &sourceElement=0, const UInt32 &targetElement=0, const UInt32 &elements=1) const
Performs a buffer-to-buffer transfer from source to target .
Definition: rendering_api.hpp:3606
void bind(const IIndexBuffer &buffer) const noexcept
Binds a index buffer to the pipeline.
Definition: rendering_api.hpp:3737
void use(const IPipeline &pipeline) const noexcept
Sets the active pipeline state.
Definition: rendering_api.hpp:3698
void generateMipMaps(IImage &image) noexcept
Uses the image at level 0 to generate mip-maps for the remaining levels.
Definition: rendering_api.hpp:3593
virtual void dispatch(const Vector3u &threadCount) const noexcept=0
Executes a compute shader.
virtual void draw(const UInt32 &vertices, const UInt32 &instances=1, const UInt32 &firstVertex=0, const UInt32 &firstInstance=0) const noexcept=0
Draws a number of vertices from the currently bound vertex buffer.
virtual ~ICommandBuffer() noexcept=default
void bind(const IVertexBuffer &buffer) const noexcept
Binds a vertex buffer to the pipeline.
Definition: rendering_api.hpp:3724
void transfer(const IBuffer &source, const IImage &target, const UInt32 &sourceElement=0, const UInt32 &firstSubresource=0, const UInt32 &elements=1) const
Performs a buffer-to-image transfer from source to target .
Definition: rendering_api.hpp:3642
The interface for a command queue.
Definition: rendering_api.hpp:4215
virtual ~ICommandQueue() noexcept=default
virtual UInt64 currentFence() const noexcept=0
Returns the value of the latest fence inserted into the queue.
UInt64 submit(const ICommandBuffer &commandBuffer) const
Submits a single command buffer and inserts a fence to wait for it.
Definition: rendering_api.hpp:4274
UInt64 submit(const Array< const ICommandBuffer * > &commandBuffers) const
Submits a set of command buffers and inserts a fence to wait for them.
Definition: rendering_api.hpp:4287
virtual void waitFor(const UInt64 &fence) const noexcept=0
Waits for a certain fence value to complete on the command queue.
The interface for a compute pipeline.
Definition: rendering_api.hpp:3916
virtual ~IComputePipeline() noexcept=default
Describes a the layout of a single descriptor within a DescriptorSet.
Definition: rendering_api.hpp:2613
virtual ~IDescriptorLayout() noexcept=default
The interface for a descriptor set.
Definition: rendering_api.hpp:3072
void attach(const UInt32 &binding, const IImage &image) const
Attaches an image as an input attachment to a descriptor bound at .
Definition: rendering_api.hpp:3129
void update(const UInt32 &binding, const IImage &texture, const UInt32 &descriptor=0, const UInt32 &firstLevel=0, const UInt32 &levels=0, const UInt32 &firstLayer=0, const UInt32 &layers=0) const
Updates a texture within the current descriptor set.
Definition: rendering_api.hpp:3110
void update(const UInt32 &binding, const ISampler &sampler, const UInt32 &descriptor=0) const
Updates a sampler within the current descriptor set.
Definition: rendering_api.hpp:3120
virtual ~IDescriptorSet() noexcept=default
The interface for a descriptor set layout.
Definition: rendering_api.hpp:3143
virtual ~IDescriptorSetLayout() noexcept=default
Array< UniquePtr< IDescriptorSet > > allocateMultiple(const UInt32 &descriptorSets, const UInt32 &descriptors=0) const
Allocates an array of descriptor sets.
Definition: rendering_api.hpp:3260
void free(const IDescriptorSet &descriptorSet) const noexcept
Marks a descriptor set as unused, so that it can be handed out again instead of allocating a new one.
Definition: rendering_api.hpp:3268
virtual const UInt32 & space() const noexcept=0
Returns the space index of the descriptor set.
virtual const IDescriptorLayout & descriptor(const UInt32 &binding) const =0
Returns the descriptor layout for the descriptor bound to the binding point provided with binding .
Describes a chunk of device memory.
Definition: rendering_api.hpp:2676
virtual ~IDeviceMemory() noexcept=default
The interface for a frame buffer.
Definition: rendering_api.hpp:3924
virtual void resize(const Size2d &renderArea)=0
Causes the frame buffer to be invalidated and recreated with a new size.
virtual const ICommandBuffer & commandBuffer(const UInt32 &index) const =0
Returns a command buffer that records draw commands for the frame buffer.
virtual const IImage & image(const UInt32 &location) const =0
Returns the image that stores the output attachment for the render target mapped the location passed ...
Array< const IImage * > images() const noexcept
Returns the images that store the output attachments for the render targets of the RenderPass.
Definition: rendering_api.hpp:3988
virtual ~IFrameBuffer() noexcept=default
Represents a physical graphics adapter.
Definition: rendering_api.hpp:1754
virtual ~IGraphicsAdapter() noexcept=default
The interface for a graphics device that.
Definition: rendering_api.hpp:4582
virtual MultiSamplingLevel maximumMultiSamplingLevel(const Format &format) const noexcept=0
Queries the device for the maximum supported number of multi-sampling levels.
virtual ~IGraphicsDevice() noexcept=default
virtual void wait() const =0
Waits until the device is idle.
The interface for a graphics factory.
Definition: rendering_api.hpp:4324
Array< UniquePtr< IImage > > createTextures(const UInt32 &elements, const Format &format, const Size3d &size, const ImageDimensions &dimension=ImageDimensions::DIM_2, const UInt32 &layers=1, const UInt32 &levels=1, const MultiSamplingLevel &samples=MultiSamplingLevel::x1, const bool &allowWrite=false) const
Creates an array of textures, based on the layout .
Definition: rendering_api.hpp:4499
UniquePtr< IBuffer > createBuffer(const String &name, const BufferType &type, const BufferUsage &usage, const size_t &elementSize, const UInt32 &elements=1, const bool &allowWrite=false) const
Creates a buffer of type type .
Definition: rendering_api.hpp:4352
UniquePtr< IImage > createTexture(const Format &format, const Size3d &size, const ImageDimensions &dimension=ImageDimensions::DIM_2, const UInt32 &levels=1, const UInt32 &layers=1, const MultiSamplingLevel &samples=MultiSamplingLevel::x1, const bool &allowWrite=false) const
Creates a texture, based on the layout .
Definition: rendering_api.hpp:4461
UniquePtr< IVertexBuffer > createVertexBuffer(const IVertexBufferLayout &layout, const BufferUsage &usage, const UInt32 &elements=1) const
Creates a vertex buffer, based on the layout
Definition: rendering_api.hpp:4368
virtual ~IGraphicsFactory() noexcept=default
UniquePtr< ISampler > createSampler(const String &name, const FilterMode &magFilter=FilterMode::Nearest, const FilterMode &minFilter=FilterMode::Nearest, const BorderMode &borderU=BorderMode::Repeat, const BorderMode &borderV=BorderMode::Repeat, const BorderMode &borderW=BorderMode::Repeat, const MipMapMode &mipMapMode=MipMapMode::Nearest, const Float &mipMapBias=0.f, const Float &maxLod=std::numeric_limits< Float >::max(), const Float &minLod=0.f, const Float &anisotropy=0.f) const
Creates a texture sampler, based on the layout .
Definition: rendering_api.hpp:4538
UniquePtr< IIndexBuffer > createIndexBuffer(const String &name, const IIndexBufferLayout &layout, const BufferUsage &usage, const UInt32 &elements) const
Creates an index buffer, based on the layout .
Definition: rendering_api.hpp:4418
UniquePtr< IImage > createAttachment(const String &name, const Format &format, const Size2d &size, const MultiSamplingLevel &samples=MultiSamplingLevel::x1) const
Creates an image that is used as render target attachment.
Definition: rendering_api.hpp:4441
Array< UniquePtr< ISampler > > createSamplers(const UInt32 &elements, const FilterMode &magFilter=FilterMode::Nearest, const FilterMode &minFilter=FilterMode::Nearest, const BorderMode &borderU=BorderMode::Repeat, const BorderMode &borderV=BorderMode::Repeat, const BorderMode &borderW=BorderMode::Repeat, const MipMapMode &mipMapMode=MipMapMode::Nearest, const Float &mipMapBias=0.f, const Float &maxLod=std::numeric_limits< Float >::max(), const Float &minLod=0.f, const Float &anisotropy=0.f) const
Creates an array of texture samplers, based on the layout .
Definition: rendering_api.hpp:4558
UniquePtr< IImage > createTexture(const String &name, const Format &format, const Size3d &size, const ImageDimensions &dimension=ImageDimensions::DIM_2, const UInt32 &levels=1, const UInt32 &layers=1, const MultiSamplingLevel &samples=MultiSamplingLevel::x1, const bool &allowWrite=false) const
Creates a texture, based on the layout .
Definition: rendering_api.hpp:4482
UniquePtr< IVertexBuffer > createVertexBuffer(const String &name, const IVertexBufferLayout &layout, const BufferUsage &usage, const UInt32 &elements=1) const
Creates a vertex buffer, based on the layout
Definition: rendering_api.hpp:4385
UniquePtr< ISampler > createSampler(const FilterMode &magFilter=FilterMode::Nearest, const FilterMode &minFilter=FilterMode::Nearest, const BorderMode &borderU=BorderMode::Repeat, const BorderMode &borderV=BorderMode::Repeat, const BorderMode &borderW=BorderMode::Repeat, const MipMapMode &mipMapMode=MipMapMode::Nearest, const Float &mipMapBias=0.f, const Float &maxLod=std::numeric_limits< Float >::max(), const Float &minLod=0.f, const Float &anisotropy=0.f) const
Creates a texture sampler, based on the layout .
Definition: rendering_api.hpp:4518
UniquePtr< IImage > createAttachment(const Format &format, const Size2d &size, const MultiSamplingLevel &samples=MultiSamplingLevel::x1) const
Creates an image that is used as render target attachment.
Definition: rendering_api.hpp:4429
UniquePtr< IIndexBuffer > createIndexBuffer(const IIndexBufferLayout &layout, const BufferUsage &usage, const UInt32 &elements) const
Creates an index buffer, based on the layout .
Definition: rendering_api.hpp:4401
Describes a generic image.
Definition: rendering_api.hpp:2789
virtual ~IImage() noexcept=default
The interface for an index buffer.
Definition: rendering_api.hpp:3458
virtual ~IIndexBuffer() noexcept=default
Describes a index buffer layout.
Definition: rendering_api.hpp:2579
virtual ~IIndexBufferLayout() noexcept=default
The interface for an input assembler state.
Definition: rendering_api.hpp:3473
virtual const IIndexBufferLayout & indexBufferLayout() const =0
Returns the index buffer layout.
virtual const PrimitiveTopology & topology() const noexcept=0
Returns the primitive topology.
virtual ~IInputAssembler() noexcept=default
virtual const IVertexBufferLayout & vertexBufferLayout(const UInt32 &binding) const =0
Returns the vertex buffer layout for binding provided with binding .
Allows for data to be mapped into the object.
Definition: rendering_api.hpp:2651
virtual ~IMappable() noexcept=default
The interface for a pipeline.
Definition: rendering_api.hpp:3512
virtual ~IPipeline() noexcept=default
SharedPtr< const IPipelineLayout > layout() const noexcept
Returns the layout of the render pipeline.
Definition: rendering_api.hpp:3529
The interface for a pipeline layout.
Definition: rendering_api.hpp:3410
virtual const IPushConstantsLayout * pushConstants() const noexcept=0
Returns the push constants layout, or nullptr, if the pipeline does not use any push constants.
virtual ~IPipelineLayout() noexcept=default
The interface for a push constants layout.
Definition: rendering_api.hpp:3323
virtual ~IPushConstantsLayout() noexcept=default
Describes a range within a IPushConstantsLayout.
Definition: rendering_api.hpp:3282
virtual ~IPushConstantsRange() noexcept=default
Represents the rasterizer state of a RenderPipeline.
Definition: rendering_api.hpp:2244
virtual ~IRasterizer() noexcept=default
The interface to access a render backend.
Definition: rendering_api.hpp:4692
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:4737
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 ~IRenderBackend() noexcept=default
virtual const IGraphicsAdapter * findAdapter(const Optional< UInt64 > &adapterId=std::nullopt) const =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:4746
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...
The interface for a render pass.
Definition: rendering_api.hpp:4019
virtual ~IRenderPass() noexcept=default
virtual Span< const RenderTarget > renderTargets() const noexcept=0
Returns the list of render targets, the render pass renders into.
virtual const RenderTarget & renderTarget(const UInt32 &location) const =0
Returns the render target mapped to the location provided by location .
Array< const IRenderPipeline * > pipelines() const noexcept
Returns an array of all render pipelines, owned by the render pass.
Definition: rendering_api.hpp:4048
The interface for a render pipeline.
Definition: rendering_api.hpp:3840
SharedPtr< IRasterizer > rasterizer() const noexcept
Returns the rasterizer state used by the render pipeline.
Definition: rendering_api.hpp:3857
virtual Array< const IViewport * > viewports() const noexcept=0
Returns the viewports, the render pipeline can draw to.
virtual ~IRenderPipeline() noexcept=default
Represents a render target, i.e. an abstract view of the output of an RenderPass.
Definition: rendering_api.hpp:1862
virtual ~IRenderTarget() noexcept=default
Describes a texture sampler.
Definition: rendering_api.hpp:2872
virtual ~ISampler() noexcept=default
The interface of a scissor.
Definition: rendering_api.hpp:2415
virtual ~IScissor() noexcept=default
Represents a single shader module, i.e. a part of a IShaderProgram.
Definition: rendering_api.hpp:1827
virtual ~IShaderModule() noexcept=default
The interface for a shader program.
Definition: rendering_api.hpp:3361
virtual ~IShaderProgram() noexcept=default
SharedPtr< IPipelineLayout > reflectPipelineLayout() const
Uses shader reflection to extract the pipeline layout of a shader. May not be available in all backen...
Definition: rendering_api.hpp:3398
The interface for a state resource.
Definition: rendering_api.hpp:1438
virtual ~IStateResource() noexcept=default
Represents a surface to render to.
Definition: rendering_api.hpp:1815
virtual ~ISurface() noexcept=default
Interface for a swap chain.
Definition: rendering_api.hpp:4140
virtual void present(const IFrameBuffer &frameBuffer) const =0
Queues a present that gets executed after frameBuffer signals its readiness.
virtual Array< Format > getSurfaceFormats() const noexcept=0
Returns an array of supported formats, that can be drawn to the surface.
virtual ~ISwapChain() noexcept=default
The interface for a vertex buffer.
Definition: rendering_api.hpp:3443
virtual ~IVertexBuffer() noexcept=default
Describes a vertex buffer layout.
Definition: rendering_api.hpp:2563
virtual ~IVertexBufferLayout() noexcept=default
Interface for a viewport.
Definition: rendering_api.hpp:2331
virtual ~IViewport() noexcept=default
Implements a IRasterizer.
Definition: rendering_api.hpp:2287
virtual ~Rasterizer() noexcept
Implements a render target.
Definition: rendering_api.hpp:1994
virtual ~RenderTarget() noexcept
Implements a scissor.
Definition: rendering_api.hpp:2436
Scissor(Scissor &&) noexcept=delete
Base class for a resource that can be identified by a name string within a DeviceState.
Definition: rendering_api.hpp:1453
StateResource(const StateResource &)=delete
virtual ~StateResource() noexcept
StateResource(StateResource &&)=delete
Implements a viewport.
Definition: rendering_api.hpp:2376
Viewport(Viewport &&) noexcept=delete
Implements the IResource interface.
Definition: containers.hpp:371
Definition: math.hpp:30
uint32_t UInt32
Definition: math.hpp:37
uint16_t UInt16
Definition: math.hpp:35
float_t Float
Definition: math.hpp:40
uint64_t UInt64
Definition: math.hpp:39
int32_t Int32
Definition: math.hpp:36
uint8_t Byte
Definition: math.hpp:33
Definition: dx12.hpp:8
UInt32 getBufferFormatChannels(const BufferFormat &format)
Returns the number of channels for a buffer format.
Definition: rendering_api.hpp:1398
LITEFX_DEFINE_FLAGS(QueueType)
bool LITEFX_RENDERING_API hasStencil(const Format &format)
Returns true, if the format contains a stencil channel.
Definition: convert.cpp:187
bool LITEFX_RENDERING_API hasDepth(const Format &format)
Returns true, if the format contains a depth channel.
Definition: convert.cpp:173
size_t LITEFX_RENDERING_API getSize(const Format &format)
Returns the size of an element of a specified format.
Definition: convert.cpp:6
UInt32 getBufferFormatChannelSize(const BufferFormat &format)
Returns the number of bytes used by a channel of a buffer format.
Definition: rendering_api.hpp:1406
UInt32 getBufferFormatType(const BufferFormat &format)
Returns the underlying data type of a buffer format.
Definition: rendering_api.hpp:1414
Definition: app.hpp:6
std::string String
Definition: string.hpp:19
std::vector< T > Array
Represents a dynamic array.
Definition: containers.hpp:58
std::span< T > Span
Represents a view of an array.
Definition: containers.hpp:72
std::shared_ptr< T > SharedPtr
Represents a shared pointer, that expresses non-exclusive ownership.
Definition: containers.hpp:94
std::unique_ptr< T, TDeleter > UniquePtr
Represents a unique pointer, that expresses exclusive ownership.
Definition: containers.hpp:87
std::string_view StringView
Definition: string.hpp:21
std::optional< T > Optional
Represents an optional value.
Definition: containers.hpp:79
Definition: graphics.hpp:11
Describes the rasterizer depth bias.
Definition: rendering_api.hpp:2100
Describes the rasterizer depth state.
Definition: rendering_api.hpp:2073
Describes the rasterizer stencil state.
Definition: rendering_api.hpp:2152
Describes a stencil test for either front or back faces.
Definition: rendering_api.hpp:2126
Describes the blend state of the render target.
Definition: rendering_api.hpp:1867