3#include <litefx/config.h>
5#if !defined (LITEFX_DIRECTX12_API)
6# if defined(LiteFX_Backends_DirectX12_EXPORTS) && (defined _WIN32 || defined WINCE)
7# define LITEFX_DIRECTX12_API __declspec(dllexport)
8# elif (defined(LiteFX_Backends_DirectX12_EXPORTS) || defined(__APPLE__)) && defined __GNUC__ && __GNUC__ >= 4
9# define LITEFX_DIRECTX12_API __attribute__ ((visibility ("default")))
10# elif !defined(LiteFX_Backends_DirectX12_EXPORTS) && (defined _WIN32 || defined WINCE)
11# define LITEFX_DIRECTX12_API __declspec(dllimport)
15#ifndef LITEFX_DIRECTX12_API
16# define LITEFX_DIRECTX12_API
19#if (!defined _WIN32 && !defined WINCE)
20# pragma message ("DirectX12: The DirectX backend requires Windows to be built on.")
23#ifdef LITEFX_DEFINE_GLOBAL_EXPORTS
24#include <d3d12agility.hpp>
27#include <directx/d3d12.h>
28#include <directx/dxcore.h>
29#include <directx/d3dx12.h>
30#include <dxguids/dxguids.h>
36using namespace Microsoft::WRL;
38#include <litefx/rendering.hpp>
39#include "dx12_formatters.hpp"
84#if defined(LITEFX_BUILD_DEFINE_BUILDERS)
86 class DirectX12VertexBufferLayoutBuilder;
87 class DirectX12DescriptorSetLayoutBuilder;
88 class DirectX12PushConstantsLayoutBuilder;
89 class DirectX12PipelineLayoutBuilder;
90 class DirectX12ShaderProgramBuilder;
91 class DirectX12InputAssemblerBuilder;
92 class DirectX12RasterizerBuilder;
93 class DirectX12RenderPipelineBuilder;
94 class DirectX12ComputePipelineBuilder;
95 class DirectX12RayTracingPipelineBuilder;
96 class DirectX12RenderPassBuilder;
97 class DirectX12BarrierBuilder;
104 template <
class THandle>
257 static inline auto create(ComPtr<IDXGIAdapter4> adapter) {
263 String name()
const override;
266 UInt64 uniqueId() const noexcept override;
269 UInt32 vendorId() const noexcept override;
272 UInt32 deviceId() const noexcept override;
278 UInt64 driverVersion() const noexcept override;
281 UInt32 apiVersion() const noexcept override;
284 UInt64 dedicatedMemory() const noexcept override;
328 RuntimeException(
"{1} (HRESULT 0x{0:08X})", static_cast<unsigned>(result), _com_error(result).ErrorMessage()), m_code(result), m_error(result) { }
336 RuntimeException(
"{2} {1} (HRESULT 0x{0:08X})", static_cast<unsigned>(result), _com_error(result).ErrorMessage(), message), m_code(result), m_error(result) { }
344 template <
typename ...TArgs>
368 const _com_error& error() const noexcept {
376 HRESULT
code() const noexcept {
387 template <
typename ...TArgs>
388 static inline void raiseIfFailed(HRESULT hr, std::format_string<TArgs...> message, TArgs&&... args) {
389 if (SUCCEEDED(hr)) [[likely]]
392 throw DX12PlatformException(hr, message, std::forward<TArgs>(args)...);
Definition adapter.cpp:10
Implements the DirectX 12 RenderBackend.
Definition dx12.hpp:2915
Implements a DirectX 12 resource barrier.
Definition dx12.hpp:484
Implements a DirectX 12 bottom-level acceleration structure (BLAS).
Definition dx12.hpp:302
Records commands for a DirectX12Queue
Definition dx12.hpp:1435
Implements a DirectX 12 ComputePipeline.
Definition dx12.hpp:1877
Implements a DirectX 12 IDescriptorLayout
Definition dx12.hpp:777
Implements a DirectX 12 DescriptorSet.
Definition dx12.hpp:697
Implements a DirectX 12 DescriptorSetLayout.
Definition dx12.hpp:857
Implements a DirectX 12 graphics device.
Definition dx12.hpp:2667
Implements a DirectX 12 frame buffer.
Definition dx12.hpp:2020
Implements a DirectX12 IGraphicsAdapter.
Definition dx12_api.hpp:224
A graphics factory that produces objects for a DirectX12Device.
Definition dx12.hpp:2516
Implements a DirectX 12 index buffer layout.
Definition dx12.hpp:119
Implements a DirectX 12 PipelineLayout.
Definition dx12.hpp:1130
Defines the base class for DirectX 12 pipeline state objects.
Definition dx12.hpp:1411
Implements the DirectX 12 PushConstantsLayout.
Definition dx12.hpp:1073
Implements the DirectX 12 IPushConstantsRange.
Definition dx12.hpp:1015
Implements a DirectX 12 command queue.
Definition dx12.hpp:1688
Implements a DirectX 12 IRasterizer.
Definition dx12.hpp:1332
Implements a DirectX 12 RayTracingPipeline.
Definition dx12.hpp:1938
Implements a DirectX 12 render pass.
Definition dx12.hpp:2182
Implements a DirectX 12 RenderPipeline.
Definition dx12.hpp:1800
Implements a DirectX 12 IShaderModule.
Definition dx12.hpp:563
Implements a DirectX 12 ShaderProgram.
Definition dx12.hpp:623
Implements a DirectX12 ISurface.
Definition dx12_api.hpp:290
DirectX12Surface(const DirectX12Surface &)=delete
DirectX12Surface(DirectX12Surface &&) noexcept=default
Implements a DirectX 12 swap chain.
Definition dx12.hpp:2401
Implements a DirectX 12 top-level acceleration structure (TLAS).
Definition dx12.hpp:396
Implements a DirectX 12 vertex buffer layout.
Definition dx12.hpp:21
Represents the base interface for a DirectX 12 acceleration structure implementation.
Definition dx12.hpp:286
Represents the base interface for a DirectX 12 buffer implementation.
Definition dx12.hpp:190
Represents a DirectX 12 sampled image or the base interface for a texture.
Definition dx12.hpp:249
Represents a DirectX 12 index buffer.
Definition dx12.hpp:227
Represents a DirectX 12 sampler.
Definition dx12.hpp:268
Represents a DirectX 12 vertex buffer.
Definition dx12.hpp:207
Represents a physical graphics adapter.
Definition rendering_api.hpp:3222
Represents a surface to render to.
Definition rendering_api.hpp:3294
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
static auto create(TArgs &&... args) -> SharedPtr< T >
Generic factory method used to create instances of the shared object.
Definition containers.hpp:1114
uint64_t UInt64
A type for an unsigned 64 bit integer.
Definition math.hpp:71
uint32_t UInt32
A type for an unsigned 32 bit integer.
Definition math.hpp:61
PolygonMode LITEFX_DIRECTX12_API getPolygonMode(const D3D12_FILL_MODE &mode)
Definition convert.cpp:381
Format LITEFX_DIRECTX12_API getFormat(const DXGI_FORMAT &format)
Definition convert.cpp:5
D3D12_BLEND_OP LITEFX_DIRECTX12_API getBlendOperation(BlendOperation blendOperation)
Definition convert.cpp:601
D3D12_BARRIER_SYNC LITEFX_DIRECTX12_API getPipelineStage(PipelineStage pipelineStage)
Definition convert.cpp:613
CullMode LITEFX_DIRECTX12_API getCullMode(const D3D12_CULL_MODE &mode)
Definition convert.cpp:407
D3D12_PRIMITIVE_TOPOLOGY_TYPE LITEFX_DIRECTX12_API getPrimitiveTopologyType(PrimitiveTopology topology)
Definition convert.cpp:475
PrimitiveTopology LITEFX_DIRECTX12_API getPrimitiveTopology(const D3D12_PRIMITIVE_TOPOLOGY &topology)
Definition convert.cpp:437
D3D12_BARRIER_LAYOUT LITEFX_DIRECTX12_API getImageLayout(ImageLayout imageLayout)
Definition convert.cpp:723
D3D12_BLEND LITEFX_DIRECTX12_API getBlendFactor(BlendFactor blendFactor)
Definition convert.cpp:575
D3D12_RESOURCE_DIMENSION LITEFX_DIRECTX12_API getImageType(ImageDimensions dimensions)
Definition convert.cpp:365
LPCTSTR LITEFX_DIRECTX12_API getSemanticName(AttributeSemantic semantic)
Definition convert.cpp:492
D3D12_STENCIL_OP LITEFX_DIRECTX12_API getStencilOp(StencilOperation stencilOp)
Definition convert.cpp:560
String LITEFX_DIRECTX12_API getVendorName(UInt32 vendorId)
Definition convert.cpp:523
D3D12_COMPARISON_FUNC LITEFX_DIRECTX12_API getCompareOp(CompareOperation compareOp)
Definition convert.cpp:545
D3D12_BARRIER_ACCESS LITEFX_DIRECTX12_API getResourceAccess(ResourceAccess resourceAccess)
Definition convert.cpp:665
bool LITEFX_DIRECTX12_API isSRGB(Format format)
Definition convert.cpp:348
constexpr StringView DIRECTX12_LOG
Definition dx12_api.hpp:45
ImageLayout
Specifies the layout of an IImage resource.
Definition rendering_api.hpp:1858
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
GraphicsAdapterType
Defines different types of graphics adapters.
Definition rendering_api.hpp:76
CompareOperation
Describes the operation used to compare depth or stencil values during depth/stencil tests.
Definition rendering_api.hpp:1387
BlendOperation
Specifies a blend operation.
Definition rendering_api.hpp:1531
PrimitiveTopology
Describes the topology of a mesh primitive.
Definition rendering_api.hpp:937
PolygonMode
Describes the draw mode for polygons.
Definition rendering_api.hpp:1142
AttributeSemantic
Describes the semantic of a buffer attribute.
Definition rendering_api.hpp:372
ImageDimensions
Describes the dimensions of a image resource, i.e. the dimensions that are required to access a texel...
Definition rendering_api.hpp:1258
StencilOperation
An operation that is applied to the stencil buffer.
Definition rendering_api.hpp:1433
PipelineStage
Defines pipeline stages as points where synchronization may occur.
Definition rendering_api.hpp:1545
BufferFormat
Describes a buffer attribute format.
Definition rendering_api.hpp:340
ResourceAccess
Defines how a IBuffer or IImage resource is accessed.
Definition rendering_api.hpp:1709
Format
Describes a texel format.
Definition rendering_api.hpp:183
std::string String
Definition string.hpp:24
std::string_view StringView
Definition string.hpp:26
An allocator used to allocate the shared object.
Definition containers.hpp:1098