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// Qt-Security score:significant reason:default
4
6#include <QtCore/private/qsystemlibrary_p.h>
7#include <QtCore/private/qsystemerror_p.h>
8
10
11namespace QRhiD3D {
12
14{
15 for (const wchar_t *libraryName : {L"D3DCompiler_47", L"D3DCompiler_43"}) {
16 QSystemLibrary library(libraryName);
17 if (library.load()) {
18 if (auto symbol = library.resolve("D3DCompile"))
19 return reinterpret_cast<pD3DCompile>(symbol);
20 } else {
21 qWarning("Failed to load D3DCompiler_47/43.dll");
22 }
23 }
24 return nullptr;
25}
26
28{
29 QSystemLibrary dcomplib(QStringLiteral("dcomp"));
30 typedef HRESULT (__stdcall *DCompositionCreateDeviceFuncPtr)(
31 _In_opt_ IDXGIDevice *dxgiDevice,
32 _In_ REFIID iid,
33 _Outptr_ void **dcompositionDevice);
34 DCompositionCreateDeviceFuncPtr func = reinterpret_cast<DCompositionCreateDeviceFuncPtr>(
35 dcomplib.resolve("DCompositionCreateDevice"));
36 if (!func) {
37 qWarning("Unable to resolve DCompositionCreateDevice, perhaps dcomp.dll is missing?");
38 return nullptr;
39 }
40 IDCompositionDevice *device = nullptr;
41 HRESULT hr = func(nullptr, __uuidof(IDCompositionDevice), reinterpret_cast<void **>(&device));
42 if (FAILED(hr)) {
43 qWarning("Failed to create Direct Composition device: %s",
44 qPrintable(QSystemError::windowsComString(hr)));
45 return nullptr;
46 }
47 return device;
48}
49
50#ifdef QRHI_D3D12_HAS_DXC
52{
54 // this will not be in the system library location, hence onlySystemDirectory==false
55 if (!dxclib.load(false)) {
56 qWarning("Failed to load dxcompiler.dll");
57 return {};
58 }
59 DxcCreateInstanceProc func = reinterpret_cast<DxcCreateInstanceProc>(dxclib.resolve("DxcCreateInstance"));
60 if (!func) {
61 qWarning("Unable to resolve DxcCreateInstance");
62 return {};
63 }
64 IDxcCompiler *compiler = nullptr;
65 HRESULT hr = func(CLSID_DxcCompiler, __uuidof(IDxcCompiler), reinterpret_cast<void**>(&compiler));
66 if (FAILED(hr)) {
67 qWarning("Failed to create dxc compiler instance: %s",
69 return {};
70 }
71 IDxcLibrary *library = nullptr;
72 hr = func(CLSID_DxcLibrary, __uuidof(IDxcLibrary), reinterpret_cast<void**>(&library));
73 if (FAILED(hr)) {
74 qWarning("Failed to create dxc library instance: %s",
76 return {};
77 }
78 return { compiler, library };
79}
80#endif
81
91
92} // namespace
93
94QT_END_NAMESPACE
pD3DCompile resolveD3DCompile()
IDCompositionDevice * createDirectCompositionDevice()
void fillDriverInfo(QRhiDriverInfo *info, const DXGI_ADAPTER_DESC1 &desc)
Combined button and popup list for selecting options.