Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
Toggle main menu visibility
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
5
#
include
"qrhid3dhelpers_p.h"
6
#
include
<
QtCore
/
private
/
qsystemlibrary_p
.
h
>
7
#
include
<
QtCore
/
private
/
qsystemerror_p
.
h
>
8
9
QT_BEGIN_NAMESPACE
10
11
namespace
QRhiD3D
{
12
13
pD3DCompile
resolveD3DCompile
()
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
27
IDCompositionDevice
*
createDirectCompositionDevice
()
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
51
std
::
pair
<
IDxcCompiler
*,
IDxcLibrary
*>
createDxcCompiler
()
52
{
53
QSystemLibrary
dxclib
(
QStringLiteral
(
"dxcompiler"
));
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"
,
68
qPrintable
(
QSystemError
::
windowsComString
(
hr
)));
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"
,
75
qPrintable
(
QSystemError
::
windowsComString
(
hr
)));
76
return
{};
77
}
78
return
{
compiler
,
library
};
79
}
80
#
endif
81
82
void
fillDriverInfo
(
QRhiDriverInfo
*
info
,
const
DXGI_ADAPTER_DESC1
&
desc
)
83
{
84
const
QString
name
=
QString
::
fromUtf16
(
reinterpret_cast
<
const
char16_t
*>(
desc
.
Description
));
85
info
->
deviceName
=
name
.
toUtf8
();
86
info
->
deviceId
=
desc
.
DeviceId
;
87
info
->
vendorId
=
desc
.
VendorId
;
88
info
->
deviceType
= (
desc
.
Flags
&
DXGI_ADAPTER_FLAG_SOFTWARE
) ?
QRhiDriverInfo
::
CpuDevice
89
:
QRhiDriverInfo
::
UnknownDevice
;
90
}
91
92
}
// namespace
93
94
QT_END_NAMESPACE
QRhiD3D
Definition
qrhid3dhelpers.cpp:11
QRhiD3D::resolveD3DCompile
pD3DCompile resolveD3DCompile()
Definition
qrhid3dhelpers.cpp:13
QRhiD3D::createDirectCompositionDevice
IDCompositionDevice * createDirectCompositionDevice()
Definition
qrhid3dhelpers.cpp:27
QRhiD3D::fillDriverInfo
void fillDriverInfo(QRhiDriverInfo *info, const DXGI_ADAPTER_DESC1 &desc)
Definition
qrhid3dhelpers.cpp:82
QT_BEGIN_NAMESPACE
Combined button and popup list for selecting options.
Definition
qsequentialanimationgroup.cpp:47
qtbase
src
gui
rhi
qrhid3dhelpers.cpp
Generated on
for Qt by
1.18.0