3#if !defined (LITEFX_DIRECTX12_API)
4# if defined(LiteFX_Backends_DirectX12_EXPORTS) && (defined _WIN32 || defined WINCE)
5# define LITEFX_DIRECTX12_API __declspec(dllexport)
6# elif (defined(LiteFX_Backends_DirectX12_EXPORTS) || defined(__APPLE__)) && defined __GNUC__ && __GNUC__ >= 4
7# define LITEFX_DIRECTX12_API __attribute__ ((visibility ("default")))
8# elif !defined(LiteFX_Backends_DirectX12_EXPORTS) && (defined _WIN32 || defined WINCE)
9# define LITEFX_DIRECTX12_API __declspec(dllimport)
13#ifndef LITEFX_DIRECTX12_API
14# define LITEFX_DIRECTX12_API
17#if (!defined _WIN32 && !defined WINCE)
18# pragma message ("DirectX12: The DirectX backend requires Windows to be built on.")
21#include <directx/d3d12.h>
22#include <directx/dxcore.h>
23#include <directx/d3dx12.h>
24#include <dxguids/dxguids.h>
30using namespace Microsoft::WRL;
32#include <litefx/config.h>
33#include <litefx/rendering.hpp>
75#if defined(BUILD_DEFINE_BUILDERS)
77 class DirectX12VertexBufferLayoutBuilder;
78 class DirectX12DescriptorSetLayoutBuilder;
79 class DirectX12PushConstantsLayoutBuilder;
80 class DirectX12PipelineLayoutBuilder;
81 class DirectX12ShaderProgramBuilder;
82 class DirectX12InputAssemblerBuilder;
83 class DirectX12RasterizerBuilder;
84 class DirectX12RenderPipelineBuilder;
85 class DirectX12ComputePipelineBuilder;
86 class DirectX12RenderPassBuilder;
93 template <
class THandle>
105 Format LITEFX_DIRECTX12_API
getFormat(
const DXGI_FORMAT& format);
110 DXGI_FORMAT LITEFX_DIRECTX12_API
getFormat(
const Format& format);
115 DXGI_FORMAT LITEFX_DIRECTX12_API
getFormat(
const BufferFormat& format);
120 bool LITEFX_DIRECTX12_API
isSRGB(
const Format& format);
125 D3D12_RESOURCE_DIMENSION LITEFX_DIRECTX12_API
getImageType(
const ImageDimensions& dimensions);
130 PolygonMode LITEFX_DIRECTX12_API
getPolygonMode(
const D3D12_FILL_MODE& mode);
135 D3D12_FILL_MODE LITEFX_DIRECTX12_API
getPolygonMode(
const PolygonMode& mode);
140 CullMode LITEFX_DIRECTX12_API
getCullMode(
const D3D12_CULL_MODE& mode);
145 D3D12_CULL_MODE LITEFX_DIRECTX12_API
getCullMode(
const CullMode& mode);
150 PrimitiveTopology LITEFX_DIRECTX12_API
getPrimitiveTopology(
const D3D12_PRIMITIVE_TOPOLOGY& topology);
155 D3D12_PRIMITIVE_TOPOLOGY LITEFX_DIRECTX12_API
getPrimitiveTopology(
const PrimitiveTopology& topology);
165 LPCTSTR LITEFX_DIRECTX12_API
getSemanticName(
const AttributeSemantic& semantic);
177 D3D12_COMPARISON_FUNC LITEFX_DIRECTX12_API
getCompareOp(
const CompareOperation& compareOp);
182 D3D12_STENCIL_OP LITEFX_DIRECTX12_API
getStencilOp(
const StencilOperation& stencilOp);
187 D3D12_BLEND LITEFX_DIRECTX12_API
getBlendFactor(
const BlendFactor& blendFactor);
192 D3D12_BLEND_OP LITEFX_DIRECTX12_API
getBlendOperation(
const BlendOperation& blendOperation);
197 D3D12_RESOURCE_STATES LITEFX_DIRECTX12_API
getResourceState(
const ResourceState& resourceState);
218 virtual
String name() const noexcept override;
221 virtual
UInt64 uniqueId() const noexcept override;
224 virtual
UInt32 vendorId() const noexcept override;
227 virtual
UInt32 deviceId() const noexcept override;
230 virtual GraphicsAdapterType type() const noexcept override;
236 virtual
UInt32 driverVersion() const noexcept override;
242 virtual
UInt32 apiVersion() const noexcept override;
245 virtual
UInt64 dedicatedMemory() const noexcept override;
265 template <typename TException, typename ...TArgs>
267 if (SUCCEEDED(hr)) [[likely]]
270 _com_error error(hr);
273 throw TException(DX12PlatformException(
"{1} (HRESULT 0x{0:08X})",
static_cast<unsigned>(hr), error.ErrorMessage()));
275 throw TException(DX12PlatformException(
"{1} (HRESULT 0x{0:08X})",
static_cast<unsigned>(hr), error.ErrorMessage()),
fmt::format(fmt::runtime(message), std::forward<TArgs>(args)...));
Definition: adapter.cpp:10
Implements the DirectX 12 RenderBackend.
Definition: dx12.hpp:1592
Implements a DirectX 12 resource barrier.
Definition: dx12.hpp:154
Records commands for a DirectX12CommandQueue
Definition: dx12.hpp:789
Implements a DirectX 12 ComputePipeline.
Definition: dx12.hpp:929
Implements a DirectX 12 IDescriptorLayout
Definition: dx12.hpp:386
Implements a DirectX 12 DescriptorSet.
Definition: dx12.hpp:317
Implements a DirectX 12 DescriptorSetLayout.
Definition: dx12.hpp:438
Implements a DirectX 12 graphics device.
Definition: dx12.hpp:1399
Implements a DirectX 12 frame buffer.
Definition: dx12.hpp:970
Implements a DirectX12 IGraphicsAdapter.
Definition: dx12_api.hpp:203
DirectX12GraphicsAdapter(const DirectX12GraphicsAdapter &)=delete
virtual ~DirectX12GraphicsAdapter() noexcept
DirectX12GraphicsAdapter(DirectX12GraphicsAdapter &&)=delete
A graphics factory that produces objects for a DirectX12Device.
Definition: dx12.hpp:1339
Implements a DirectX 12 index buffer layout.
Definition: dx12.hpp:55
Implements a DirectX 12 PipelineLayout.
Definition: dx12.hpp:655
Defines the base class for DirectX 12 pipeline state objects.
Definition: dx12.hpp:772
Implements the DirectX 12 PushConstantsLayout.
Definition: dx12.hpp:610
Implements the DirectX 12 IPushConstantsRange.
Definition: dx12.hpp:550
Implements a DirectX 12 command queue.
Definition: dx12.hpp:1276
Implements a DirectX 12 IRasterizer.
Definition: dx12.hpp:743
Implements a DirectX 12 render pass.
Definition: dx12.hpp:1065
Implements a DirectX 12 RenderPipeline.
Definition: dx12.hpp:859
Implements a DirectX 12 IShaderModule.
Definition: dx12.hpp:220
Implements a DirectX 12 ShaderProgram.
Definition: dx12.hpp:263
Implements a DirectX12 ISurface.
Definition: dx12_api.hpp:251
DirectX12Surface(const DirectX12Surface &)=delete
DirectX12Surface(DirectX12Surface &&)=delete
Implements a DirectX 12 swap chain.
Definition: dx12.hpp:1220
Implements a DirectX 12 vertex buffer layout.
Definition: dx12.hpp:18
Represents the base interface for a DirectX 12 buffer implementation.
Definition: dx12.hpp:92
Represents a DirectX 12 sampled image or the base interface for a texture.
Definition: dx12.hpp:130
Represents a DirectX 12 index buffer.
Definition: dx12.hpp:115
Represents a DirectX 12 sampler.
Definition: dx12.hpp:142
Represents a DirectX 12 vertex buffer.
Definition: dx12.hpp:102
Represents a physical graphics adapter.
Definition: rendering_api.hpp:1754
Represents a surface to render to.
Definition: rendering_api.hpp:1815
Implements the IResource interface.
Definition: containers.hpp:371
uint32_t UInt32
Definition: math.hpp:37
uint64_t UInt64
Definition: math.hpp:39
PolygonMode LITEFX_DIRECTX12_API getPolygonMode(const D3D12_FILL_MODE &mode)
Definition: convert.cpp:381
LPCTSTR LITEFX_DIRECTX12_API getSemanticName(const AttributeSemantic &semantic)
Definition: convert.cpp:492
Format LITEFX_DIRECTX12_API getFormat(const DXGI_FORMAT &format)
Definition: convert.cpp:5
CullMode LITEFX_DIRECTX12_API getCullMode(const D3D12_CULL_MODE &mode)
Definition: convert.cpp:407
D3D12_STENCIL_OP LITEFX_DIRECTX12_API getStencilOp(const StencilOperation &stencilOp)
Definition: convert.cpp:556
PrimitiveTopology LITEFX_DIRECTX12_API getPrimitiveTopology(const D3D12_PRIMITIVE_TOPOLOGY &topology)
Definition: convert.cpp:437
bool LITEFX_DIRECTX12_API isSRGB(const Format &format)
Definition: convert.cpp:348
D3D12_PRIMITIVE_TOPOLOGY_TYPE LITEFX_DIRECTX12_API getPrimitiveTopologyType(const PrimitiveTopology &topology)
Definition: convert.cpp:475
D3D12_COMPARISON_FUNC LITEFX_DIRECTX12_API getCompareOp(const CompareOperation &compareOp)
Definition: convert.cpp:541
D3D12_RESOURCE_STATES LITEFX_DIRECTX12_API getResourceState(const ResourceState &resourceState)
Definition: convert.cpp:609
D3D12_BLEND LITEFX_DIRECTX12_API getBlendFactor(const BlendFactor &blendFactor)
Definition: convert.cpp:571
String LITEFX_DIRECTX12_API getVendorName(const UInt32 &vendorId)
Definition: convert.cpp:521
D3D12_BLEND_OP LITEFX_DIRECTX12_API getBlendOperation(const BlendOperation &blendOperation)
Definition: convert.cpp:597
D3D12_RESOURCE_DIMENSION LITEFX_DIRECTX12_API getImageType(const ImageDimensions &dimensions)
Definition: convert.cpp:365
void raiseIfFailed(HRESULT hr, StringView message, TArgs &&... args)
Definition: dx12_api.hpp:266
DEFINE_EXCEPTION(DX12PlatformException, std::runtime_error)
constexpr char DIRECTX12_LOG[]
Definition: dx12_api.hpp:39
std::string String
Definition: string.hpp:19
std::string_view StringView
Definition: string.hpp:21
auto format(LiteFX::Platform t, FormatContext &ctx) const
Definition: app_formatters.hpp:8