26 D3D_FEATURE_LEVEL level;
28 D3D_DRIVER_TYPE typeAttempts[] = {
29 D3D_DRIVER_TYPE_HARDWARE,
32 const int ntypes =
int(
sizeof(typeAttempts) /
sizeof(typeAttempts[0]));
34 for (
int i = 0; i < ntypes; i++) {
35 hr = D3D11CreateDevice(
nullptr,
38 D3D11_CREATE_DEVICE_SINGLETHREADED | D3D11_CREATE_DEVICE_BGRA_SUPPORT,
51 qWarning(
"%s: Could not create Direct3D Device: %#lx",
__FUNCTION__, hr);
55 ComPtr<IDXGIDevice1> dxgiDevice;
56 ComPtr<IDXGIAdapter> dxgiAdapter;
58 hr = d3dDevice.As(&dxgiDevice);
60 qWarning(
"%s: DXGI Device interface query failed on D3D Device: %#lx",
__FUNCTION__, hr);
65 dxgiDevice->SetMaximumFrameLatency(1);
67 hr = dxgiDevice->GetAdapter(&dxgiAdapter);
69 qWarning(
"%s: Failed to probe DXGI Device for parent DXGI Adapter: %#lx",
__FUNCTION__, hr);
73 hr = dxgiAdapter->GetParent(IID_PPV_ARGS(&dxgiFactory));
75 qWarning(
"%s: Failed to probe DXGI Adapter for parent DXGI Factory: %#lx",
__FUNCTION__, hr);
79 D2D1_FACTORY_OPTIONS options = {};
81#ifdef QT_D2D_DEBUG_OUTPUT
82 qDebug(
"Turning on Direct2D debugging messages");
83 options.debugLevel = D2D1_DEBUG_LEVEL_INFORMATION;
86 hr = D2D1CreateFactory(D2D1_FACTORY_TYPE_SINGLE_THREADED, options, d2dFactory.GetAddressOf());
88 qWarning(
"%s: Could not create Direct2D Factory: %#lx",
__FUNCTION__, hr);
92 hr = d2dFactory->CreateDevice(dxgiDevice.Get(), &d2dDevice);
94 qWarning(
"%s: Could not create D2D Device: %#lx",
__FUNCTION__, hr);
98 hr = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, __uuidof(IDWriteFactory),
99 static_cast<IUnknown **>(&directWriteFactory));
101 qWarning(
"%s: Could not create DirectWrite factory: %#lx",
__FUNCTION__, hr);
105 hr = directWriteFactory->GetGdiInterop(&directWriteGdiInterop);
107 qWarning(
"%s: Could not create DirectWrite GDI Interop: %#lx",
__FUNCTION__, hr);