Diligent Engine  v.2.4.g
EngineFactoryD3D12.h
Go to the documentation of this file.
1 /*
2  * Copyright 2019-2021 Diligent Graphics LLC
3  * Copyright 2015-2019 Egor Yusov
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  *
17  * In no event and under no legal theory, whether in tort (including negligence),
18  * contract, or otherwise, unless required by applicable law (such as deliberate
19  * and grossly negligent acts) or agreed to in writing, shall any Contributor be
20  * liable for any damages, including any direct, indirect, special, incidental,
21  * or consequential damages of any character arising as a result of this License or
22  * out of the use or inability to use the software (including but not limited to damages
23  * for loss of goodwill, work stoppage, computer failure or malfunction, or any and
24  * all other commercial damages or losses), even if such Contributor has been advised
25  * of the possibility of such damages.
26  */
27 
28 #pragma once
29 
32 
33 #include "../../GraphicsEngine/interface/EngineFactory.h"
34 #include "../../GraphicsEngine/interface/RenderDevice.h"
35 #include "../../GraphicsEngine/interface/DeviceContext.h"
36 #include "../../GraphicsEngine/interface/SwapChain.h"
37 
38 #if ENGINE_DLL
39 # include "../../GraphicsEngine/interface/LoadEngineDll.h"
40 #endif
41 
43 
44 struct ICommandQueueD3D12;
45 
46 // {72BD38B0-684A-4889-9C68-0A80EC802DDE}
47 static const INTERFACE_ID IID_EngineFactoryD3D12 =
48  {0x72bd38b0, 0x684a, 0x4889, {0x9c, 0x68, 0xa, 0x80, 0xec, 0x80, 0x2d, 0xde}};
49 
50 #define DILIGENT_INTERFACE_NAME IEngineFactoryD3D12
51 #include "../../../Primitives/interface/DefineInterfaceHelperMacros.h"
52 
53 // clang-format off
54 
55 #define IEngineFactoryD3D12InclusiveMethods \
56  IEngineFactoryInclusiveMethods; \
57  IEngineFactoryD3D12Methods EngineFactoryD3D12
58 
61 {
63 
72  VIRTUAL bool METHOD(LoadD3D12)(THIS_
73  const char* DllName DEFAULT_VALUE("d3d12.dll")) PURE;
74 
76 
84  VIRTUAL void METHOD(CreateDeviceAndContextsD3D12)(THIS_
85  const EngineD3D12CreateInfo REF EngineCI,
86  IRenderDevice** ppDevice,
87  IDeviceContext** ppContexts) PURE;
88 
89 
91 
102  VIRTUAL void METHOD(AttachToD3D12Device)(THIS_
103  void* pd3d12NativeDevice,
104  size_t CommandQueueCount,
105  struct ICommandQueueD3D12** ppCommandQueues,
106  const EngineD3D12CreateInfo REF EngineCI,
107  IRenderDevice** ppDevice,
108  IDeviceContext** ppContexts) PURE;
109 
110 
112 
125  VIRTUAL void METHOD(CreateSwapChainD3D12)(THIS_
126  IRenderDevice* pDevice,
127  IDeviceContext* pImmediateContext,
129  const FullScreenModeDesc REF FSDesc,
130  const NativeWindow REF Window,
131  ISwapChain** ppSwapChain) PURE;
132 
133 
135 
149  VIRTUAL void METHOD(EnumerateAdapters)(THIS_
150  DIRECT3D_FEATURE_LEVEL MinFeatureLevel,
151  Uint32 REF NumAdapters,
152  GraphicsAdapterInfo* Adapters) PURE;
153 
154 
156 
169  VIRTUAL void METHOD(EnumerateDisplayModes)(THIS_
170  DIRECT3D_FEATURE_LEVEL MinFeatureLevel,
171  Uint32 AdapterId,
172  Uint32 OutputId,
173  TEXTURE_FORMAT Format,
174  Uint32 REF NumDisplayModes,
175  DisplayModeAttribs* DisplayModes) PURE;
176 };
178 
179 #include "../../../Primitives/interface/UndefInterfaceHelperMacros.h"
180 
181 #if DILIGENT_C_INTERFACE
182 
183 // clang-format off
184 
185 # define IEngineFactoryD3D12_LoadD3D12(This, ...) CALL_IFACE_METHOD(EngineFactoryD3D12, LoadD3D12, This, __VA_ARGS__)
186 # define IEngineFactoryD3D12_CreateDeviceAndContextsD3D12(This, ...) CALL_IFACE_METHOD(EngineFactoryD3D12, CreateDeviceAndContextsD3D12, This, __VA_ARGS__)
187 # define IEngineFactoryD3D12_CreateSwapChainD3D12(This, ...) CALL_IFACE_METHOD(EngineFactoryD3D12, CreateSwapChainD3D12, This, __VA_ARGS__)
188 # define IEngineFactoryD3D12_AttachToD3D12Device(This, ...) CALL_IFACE_METHOD(EngineFactoryD3D12, AttachToD3D12Device, This, __VA_ARGS__)
189 # define IEngineFactoryD3D12_EnumerateAdapters(This, ...) CALL_IFACE_METHOD(EngineFactoryD3D12, EnumerateAdapters, This, __VA_ARGS__)
190 # define IEngineFactoryD3D12_EnumerateDisplayModes(This, ...) CALL_IFACE_METHOD(EngineFactoryD3D12, EnumerateDisplayModes, This, __VA_ARGS__)
191 
192 // clang-format on
193 
194 #endif
195 
196 
197 #if ENGINE_DLL
198 
199 typedef struct IEngineFactoryD3D12* (*GetEngineFactoryD3D12Type)();
200 
201 inline GetEngineFactoryD3D12Type DILIGENT_GLOBAL_FUNCTION(LoadGraphicsEngineD3D12)()
202 {
203  return (GetEngineFactoryD3D12Type)LoadEngineDll("GraphicsEngineD3D12", "GetEngineFactoryD3D12");
204 }
205 
206 #else
207 
208 struct IEngineFactoryD3D12* DILIGENT_GLOBAL_FUNCTION(GetEngineFactoryD3D12)();
209 
210 #endif
211 
212 DILIGENT_END_NAMESPACE // namespace Diligent
DILIGENT_END_INTERFACE
#define DILIGENT_END_INTERFACE
Definition: DefineInterfaceHelperMacros.h:88
Diligent::INTERFACE_ID
struct INTERFACE_ID INTERFACE_ID
Definition: InterfaceID.h:54
VIRTUAL
#define VIRTUAL
Definition: DefineInterfaceHelperMacros.h:83
DILIGENT_BEGIN_INTERFACE
#define DILIGENT_BEGIN_INTERFACE(Name, Base)
Definition: CommonDefinitions.h:97
DILIGENT_GLOBAL_FUNCTION
#define DILIGENT_GLOBAL_FUNCTION(FuncName)
Definition: CommonDefinitions.h:95
Diligent::ISwapChain
Swap chain interface.
Definition: SwapChain.h:56
PURE
#define PURE
Definition: DefineInterfaceHelperMacros.h:85
Diligent::IRenderDevice
Render device interface.
Definition: RenderDevice.h:75
Diligent::ICommandQueueD3D12
Command queue interface.
Definition: CommandQueueD3D12.h:51
Diligent::DIRECT3D_FEATURE_LEVEL
DIRECT3D_FEATURE_LEVEL
Direct3D11/12 feature level.
Definition: GraphicsTypes.h:2058
DILIGENT_END_NAMESPACE
#define DILIGENT_END_NAMESPACE
Definition: CommonDefinitions.h:86
Diligent::DisplayModeAttribs
Display mode attributes.
Definition: GraphicsTypes.h:1269
Diligent::EngineD3D12CreateInfo
Attributes specific to D3D12 engine.
Definition: GraphicsTypes.h:2099
Diligent::SwapChainDesc
Swap chain description.
Definition: GraphicsTypes.h:1347
Diligent::Uint32
uint32_t Uint32
32-bit unsigned integer
Definition: BasicTypes.h:51
Diligent::SwapChainDesc
struct SwapChainDesc SwapChainDesc
Definition: GraphicsTypes.h:1421
Diligent::TEXTURE_FORMAT
TEXTURE_FORMAT
Texture formats.
Definition: GraphicsTypes.h:328
Diligent::LoadEngineDll
FARPROC LoadEngineDll(const char *EngineName, const char *GetFactoryFuncName)
Definition: LoadEngineDll.h:49
REF
#define REF
Definition: DefineGlobalFuncHelperMacros.h:39
Diligent::GraphicsAdapterInfo
Graphics adapter properties.
Definition: GraphicsTypes.h:1782
METHOD
#define METHOD(Name)
Definition: DefineInterfaceHelperMacros.h:87
DEFAULT_VALUE
#define DEFAULT_VALUE(x)
Definition: CommonDefinitions.h:99
Diligent::IDeviceContext
Device context interface.
Definition: DeviceContext.h:1460
DILIGENT_BEGIN_NAMESPACE
#define DILIGENT_BEGIN_NAMESPACE(Name)
Definition: CommonDefinitions.h:82
Diligent::IEngineFactoryD3D12
Engine factory for Direct3D12 rendering backend.
Definition: EngineFactoryD3D12.h:60
Diligent::IEngineFactory
Engine factory base interface.
Definition: EngineFactory.h:60
Diligent::GetEngineFactoryD3D12
struct IEngineFactoryD3D12 * GetEngineFactoryD3D12()
Definition: EngineFactoryD3D12.cpp:545
Diligent
The library uses Direct3D-style math:
Definition: AdvancedMath.hpp:37
THIS_
#define THIS_
Definition: DefineInterfaceHelperMacros.h:82
Diligent::FullScreenModeDesc
Full screen mode description.
Definition: GraphicsTypes.h:1425