Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Loading...
Searching...
No Matches
qrhid3dhelpers.cpp
Go to the documentation of this file.
1// Copyright (C) 2023 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3
5#include <QtCore/private/qsystemlibrary_p.h>
6#include <QtCore/private/qsystemerror_p.h>
7
9
10namespace QRhiD3D {
11
13{
14 for (const wchar_t *libraryName : {L"D3DCompiler_47", L"D3DCompiler_43"}) {
15 QSystemLibrary library(libraryName);
16 if (library.load()) {
17 if (auto symbol = library.resolve("D3DCompile"))
18 return reinterpret_cast<pD3DCompile>(symbol);
19 } else {
20 qWarning("Failed to load D3DCompiler_47/43.dll");
21 }
22 }
23 return nullptr;
24}
25
27{
28 QSystemLibrary dcomplib(QStringLiteral("dcomp"));
29 typedef HRESULT (__stdcall *DCompositionCreateDeviceFuncPtr)(
30 _In_opt_ IDXGIDevice *dxgiDevice,
31 _In_ REFIID iid,
32 _Outptr_ void **dcompositionDevice);
33 DCompositionCreateDeviceFuncPtr func = reinterpret_cast<DCompositionCreateDeviceFuncPtr>(
34 dcomplib.resolve("DCompositionCreateDevice"));
35 if (!func) {
36 qWarning("Unable to resolve DCompositionCreateDevice, perhaps dcomp.dll is missing?");
37 return nullptr;
38 }
39 IDCompositionDevice *device = nullptr;
40 HRESULT hr = func(nullptr, __uuidof(IDCompositionDevice), reinterpret_cast<void **>(&device));
41 if (FAILED(hr)) {
42 qWarning("Failed to create Direct Composition device: %s",
43 qPrintable(QSystemError::windowsComString(hr)));
44 return nullptr;
45 }
46 return device;
47}
48
49#ifdef QRHI_D3D12_HAS_DXC
51{
53 // this will not be in the system library location, hence onlySystemDirectory==false
54 if (!dxclib.load(false)) {
55 qWarning("Failed to load dxcompiler.dll");
56 return {};
57 }
58 DxcCreateInstanceProc func = reinterpret_cast<DxcCreateInstanceProc>(dxclib.resolve("DxcCreateInstance"));
59 if (!func) {
60 qWarning("Unable to resolve DxcCreateInstance");
61 return {};
62 }
63 IDxcCompiler *compiler = nullptr;
64 HRESULT hr = func(CLSID_DxcCompiler, __uuidof(IDxcCompiler), reinterpret_cast<void**>(&compiler));
65 if (FAILED(hr)) {
66 qWarning("Failed to create dxc compiler instance: %s",
68 return {};
69 }
70 IDxcLibrary *library = nullptr;
71 hr = func(CLSID_DxcLibrary, __uuidof(IDxcLibrary), reinterpret_cast<void**>(&library));
72 if (FAILED(hr)) {
73 qWarning("Failed to create dxc library instance: %s",
75 return {};
76 }
77 return { compiler, library };
78}
79#endif
80
90
91} // namespace
92
93QT_END_NAMESPACE
pD3DCompile resolveD3DCompile()
IDCompositionDevice * createDirectCompositionDevice()
void fillDriverInfo(QRhiDriverInfo *info, const DXGI_ADAPTER_DESC1 &desc)