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:2820
Implements a DirectX 12 resource barrier.
Definition dx12.hpp:477
Implements a DirectX 12 bottom-level acceleration structure (BLAS).
Definition dx12.hpp:295
Records commands for a DirectX12Queue
Definition dx12.hpp:1433
Implements a DirectX 12 ComputePipeline.
Definition dx12.hpp:1866
Implements a DirectX 12 IDescriptorLayout
Definition dx12.hpp:790
Implements a DirectX 12 DescriptorSet.
Definition dx12.hpp:705
Implements a DirectX 12 DescriptorSetLayout.
Definition dx12.hpp:866
Implements a DirectX 12 graphics device.
Definition dx12.hpp:2566
Implements a DirectX 12 frame buffer.
Definition dx12.hpp:2009
Implements a DirectX12 IGraphicsAdapter.
Definition dx12_api.hpp:224
A graphics factory that produces objects for a DirectX12Device.
Definition dx12.hpp:2471
Implements a DirectX 12 index buffer layout.
Definition dx12.hpp:112
Implements a DirectX 12 PipelineLayout.
Definition dx12.hpp:1146
Defines the base class for DirectX 12 pipeline state objects.
Definition dx12.hpp:1409
Implements the DirectX 12 PushConstantsLayout.
Definition dx12.hpp:1089
Implements the DirectX 12 IPushConstantsRange.
Definition dx12.hpp:1031
Implements a DirectX 12 command queue.
Definition dx12.hpp:1680
Implements a DirectX 12 IRasterizer.
Definition dx12.hpp:1334
Implements a DirectX 12 RayTracingPipeline.
Definition dx12.hpp:1927
Implements a DirectX 12 render pass.
Definition dx12.hpp:2148
Implements a DirectX 12 RenderPipeline.
Definition dx12.hpp:1789
Implements a DirectX 12 IShaderModule.
Definition dx12.hpp:556
Implements a DirectX 12 ShaderProgram.
Definition dx12.hpp:616
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:2356
Implements a DirectX 12 top-level acceleration structure (TLAS).
Definition dx12.hpp:389
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:279
Represents the base interface for a DirectX 12 buffer implementation.
Definition dx12.hpp:183
Represents a DirectX 12 sampled image or the base interface for a texture.
Definition dx12.hpp:242
Represents a DirectX 12 index buffer.
Definition dx12.hpp:220
Represents a DirectX 12 sampler.
Definition dx12.hpp:261
Represents a DirectX 12 vertex buffer.
Definition dx12.hpp:200
Represents a physical graphics adapter.
Definition rendering_api.hpp:2648
Represents a surface to render to.
Definition rendering_api.hpp:2720
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:66
uint32_t UInt32
A type for an unsigned 32 bit integer.
Definition math.hpp:56
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:599
D3D12_BARRIER_SYNC LITEFX_DIRECTX12_API getPipelineStage(PipelineStage pipelineStage)
Definition convert.cpp:611
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:721
D3D12_BLEND LITEFX_DIRECTX12_API getBlendFactor(BlendFactor blendFactor)
Definition convert.cpp:573
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:558
String LITEFX_DIRECTX12_API getVendorName(UInt32 vendorId)
Definition convert.cpp:521
D3D12_COMPARISON_FUNC LITEFX_DIRECTX12_API getCompareOp(CompareOperation compareOp)
Definition convert.cpp:543
D3D12_BARRIER_ACCESS LITEFX_DIRECTX12_API getResourceAccess(ResourceAccess resourceAccess)
Definition convert.cpp:663
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:1686
BlendFactor
Specifies a blend factor.
Definition rendering_api.hpp:1307
CullMode
Describes which faces are culled by the Rasterizer stage.
Definition rendering_api.hpp:991
GraphicsAdapterType
Defines different types of graphics adapters.
Definition rendering_api.hpp:75
CompareOperation
Describes the operation used to compare depth or stencil values during depth/stencil tests.
Definition rendering_api.hpp:1215
BlendOperation
Specifies a blend operation.
Definition rendering_api.hpp:1359
PrimitiveTopology
Describes the topology of a mesh primitive.
Definition rendering_api.hpp:765
PolygonMode
Describes the draw mode for polygons.
Definition rendering_api.hpp:970
AttributeSemantic
Describes the semantic of a buffer attribute.
Definition rendering_api.hpp:371
ImageDimensions
Describes the dimensions of a image resource, i.e. the dimensions that are required to access a texel...
Definition rendering_api.hpp:1086
StencilOperation
An operation that is applied to the stencil buffer.
Definition rendering_api.hpp:1261
PipelineStage
Defines pipeline stages as points where synchronization may occur.
Definition rendering_api.hpp:1373
BufferFormat
Describes a buffer attribute format.
Definition rendering_api.hpp:339
ResourceAccess
Defines how a IBuffer or IImage resource is accessed.
Definition rendering_api.hpp:1537
Format
Describes a texel format.
Definition rendering_api.hpp:182
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