MCPcopy Create free account
hub / github.com/FlaxEngine/FlaxEngine / Create

Method Create

Source/Engine/GraphicsDevice/DirectX/DX11/GPUDeviceDX11.cpp:189–335  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

187}
188
189GPUDevice* GPUDeviceDX11::Create()
190{
191 // Configuration
192#if DX11_FORCE_USE_DX10
193 D3D_FEATURE_LEVEL maxAllowedFeatureLevel = D3D_FEATURE_LEVEL_10_0;
194#elif DX11_FORCE_USE_DX10_1
195 D3D_FEATURE_LEVEL maxAllowedFeatureLevel = D3D_FEATURE_LEVEL_10_1;
196#else
197 D3D_FEATURE_LEVEL maxAllowedFeatureLevel = D3D_FEATURE_LEVEL_11_0;
198#endif
199 if (CommandLine::Options.D3D10.IsTrue())
200 maxAllowedFeatureLevel = D3D_FEATURE_LEVEL_10_0;
201 else if (CommandLine::Options.D3D11.IsTrue())
202 maxAllowedFeatureLevel = D3D_FEATURE_LEVEL_11_0;
203#if !USE_EDITOR && PLATFORM_WINDOWS
204 auto winSettings = WindowsPlatformSettings::Get();
205 if (!winSettings->SupportDX11 && !winSettings->SupportDX10)
206 {
207 // Skip if there is no support
208 LOG(Warning, "Cannot use DirectX (support disabled).");
209 return nullptr;
210 }
211 if (!winSettings->SupportDX11 && maxAllowedFeatureLevel == D3D_FEATURE_LEVEL_11_0)
212 {
213 // Downgrade if there is no SM5 support
214 maxAllowedFeatureLevel = D3D_FEATURE_LEVEL_10_0;
215 LOG(Warning, "Cannot use DirectX 11 (support disabled).");
216 }
217 if (!winSettings->SupportDX10 && maxAllowedFeatureLevel == D3D_FEATURE_LEVEL_10_0)
218 {
219 // Upgrade if there is no SM4 support
220 maxAllowedFeatureLevel = D3D_FEATURE_LEVEL_11_0;
221 LOG(Warning, "Cannot use DirectX 10 (support disabled).");
222 }
223#endif
224
225 // Create DXGI factory
226#if PLATFORM_WINDOWS
227 IDXGIFactory1* dxgiFactory;
228 IDXGIFactory6* dxgiFactory6;
229 HRESULT hr = CreateDXGIFactory1(IID_PPV_ARGS(&dxgiFactory6));
230 if (hr == S_OK)
231 dxgiFactory = dxgiFactory6;
232 else
233 {
234 dxgiFactory6 = nullptr;
235 hr = CreateDXGIFactory1(IID_PPV_ARGS(&dxgiFactory));
236 }
237#else
238 IDXGIFactory2* dxgiFactory;
239 HRESULT hr = CreateDXGIFactory1(IID_PPV_ARGS(&dxgiFactory));
240#endif
241 if (hr != S_OK)
242 {
243 LOG(Error, "Cannot create DXGI adapter. Error code: {0:x}.", hr);
244 return nullptr;
245 }
246

Callers

nothing calls this directly

Calls 10

TryCreateDeviceFunction · 0.85
BytesToTextFunction · 0.85
DeleteFunction · 0.85
GetFunction · 0.50
IsTrueMethod · 0.45
AddMethod · 0.45
CountMethod · 0.45
GetVendorIdMethod · 0.45
IsValidMethod · 0.45
InitMethod · 0.45

Tested by

no test coverage detected