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
qwindowsd3d11rhitextureimporter_p.h
Go to the documentation of this file.
1
// Copyright (C) 2026 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
#
ifndef
QWINDOWSD3D11RHITEXTUREIMPORTER_P_H
4
#
define
QWINDOWSD3D11RHITEXTUREIMPORTER_P_H
5
6
//
7
// W A R N I N G
8
// -------------
9
//
10
// This file is not part of the Qt API. It exists purely as an
11
// implementation detail. This header file may change from version to
12
// version without notice, or even be removed.
13
//
14
// We mean it.
15
//
16
17
#
include
<
QtMultimedia
/
qtmultimediaexports
.
h
>
18
#
include
<
QtMultimedia
/
qvideoframeformat
.
h
>
19
#
include
<
QtMultimedia
/
private
/
qhwvideobuffer_p
.
h
>
20
#
include
<
QtMultimedia
/
private
/
qwindowsd3d11planesplitter_p
.
h
>
21
#
include
<
QtMultimedia
/
private
/
qwindowsd3d11texturebridge_p
.
h
>
22
23
#
include
<
QtGui
/
qtguiglobal
.
h
>
24
25
#
include
<
QtCore
/
qobject
.
h
>
26
#
include
<
QtCore
/
qsize
.
h
>
27
#
include
<
QtCore
/
private
/
qcomptr_p
.
h
>
28
#
include
<
QtCore
/
private
/
quniquehandle_p
.
h
>
29
30
#
include
<
d3d11
.
h
>
31
#
include
<
d3d11_1
.
h
>
32
33
#
include
<
atomic
>
34
#
include
<
memory
>
35
#
include
<
vector
>
36
37
QT_BEGIN_NAMESPACE
38
39
class
QRhi;
40
41
namespace
QtMultimediaPrivate
{
42
43
#
if
QT_CONFIG
(
opengl
)
44
class
WglDxDeviceDeleter
45
{
46
public
:
47
WglDxDeviceDeleter
() =
default
;
48
explicit
WglDxDeviceDeleter
(
BOOL
(
WINAPI
*
closeFn
)(
HANDLE
)) :
m_closeFn
(
closeFn
) { }
49
void
operator
()(
HANDLE
device
)
const
noexcept
50
{
51
Q_ASSERT
(
m_closeFn
);
52
m_closeFn
(
device
);
53
}
54
55
private
:
56
BOOL
(
WINAPI
*
m_closeFn
)(
HANDLE
) =
nullptr
;
57
};
58
59
struct
WglDxDeviceHandleTraits
60
{
61
using
Type
=
HANDLE
;
62
static
Type
invalidValue
()
noexcept
{
return
nullptr
; }
63
};
64
using
WglDxDeviceHandle
=
QUniqueHandle
<
WglDxDeviceHandleTraits
,
WglDxDeviceDeleter
>;
65
#
endif
66
67
class
Q_MULTIMEDIA_EXPORT
QWindowsD3D11RhiTextureImporter
68
{
69
public
:
70
QWindowsD3D11RhiTextureImporter
();
71
~
QWindowsD3D11RhiTextureImporter
();
72
73
Q_DISABLE_COPY_MOVE
(
QWindowsD3D11RhiTextureImporter
)
74
75
static
bool
isRhiBackendSupported
(
QRhi
&);
76
77
/** Returns whether a texture of the given pixel format can be imported into 'rhi'. On
78
* D3D12 and OpenGL, multi-plane formats must be splittable by QWindowsD3D11PlaneSplitter. */
79
static
bool
isPixelFormatSupportedByRhiBackend
(
QRhi
&,
QVideoFrameFormat
::
PixelFormat
);
80
81
/** 'pixelFormat' is only consulted on D3D12 and OpenGL, to route multi-plane textures
82
* through QWindowsD3D11PlaneSplitter. Returns null on failure. */
83
QVideoFrameTexturesHandlesUPtr
84
importTexture
(
QRhi
&,
ID3D11Device
*
srcDevice
,
ID3D11DeviceContext
*
srcContext
,
85
const
ComPtr
<
ID3D11Texture2D
> &
texture
,
const
QSize
&
frameSize
,
86
QVideoFrameFormat
::
PixelFormat
pixelFormat
,
UINT
subresourceIndex
= 0);
87
88
private
:
89
// Textures that D3D12 imports are unwrapped from. A texture stays unwrapped until the handles
90
// of its frame are destroyed, and must neither be unwrapped again nor written to before that,
91
// so every frame in flight gets a texture of its own. Released textures are reused.
92
class
D3D12OutputTexturePool
93
{
94
public
:
95
struct
Texture
96
{
97
ComPtr
<
ID3D11Texture2D
>
texture
;
98
// Set while the handles of a frame use the texture.
99
std
::
shared_ptr
<
std
::
atomic_bool
>
inUse
;
100
};
101
102
Texture
acquire
(
ID3D11Device
*
device
,
const
D3D11_TEXTURE2D_DESC
&
desc
);
103
104
private
:
105
std
::
vector
<
Texture
>
m_textures
;
106
};
107
108
QVideoFrameTexturesHandlesUPtr
importTextureD3D11
(
QRhi
&,
ID3D11Device
*
srcDevice
,
109
ID3D11DeviceContext
*
srcContext
,
110
const
ComPtr
<
ID3D11Texture2D
> &
texture
,
111
const
QSize
&
frameSize
,
112
UINT
subresourceIndex
);
113
QVideoFrameTexturesHandlesUPtr
importTextureD3D12
(
QRhi
&,
ID3D11Device
*
srcDevice
,
114
ID3D11DeviceContext
*
srcContext
,
115
const
ComPtr
<
ID3D11Texture2D
> &
texture
,
116
const
QSize
&
frameSize
,
UINT
subresourceIndex
,
117
QWindowsD3D11TextureBridge
&
bridge
,
118
D3D12OutputTexturePool
&
outputPool
);
119
QVideoFrameTexturesHandlesUPtr
120
importSplitPlanes
(
QRhi
&
rhi
,
ID3D11Device
*
srcDevice
,
ID3D11DeviceContext
*
srcContext
,
121
const
ComPtr
<
ID3D11Texture2D
> &
texture
,
const
QSize
&
frameSize
,
122
QVideoFrameFormat
::
PixelFormat
pixelFormat
,
UINT
subresourceIndex
);
123
124
QWindowsD3D11TextureBridge
m_bridge
;
// D3D11 import, and single-plane D3D12/OpenGL import
125
QWindowsD3D11TextureBridge
m_bridge2
;
// second plane of a split multi-plane D3D12 import
126
std
::
unique_ptr
<
QWindowsD3D11PlaneSplitter
>
m_planeSplitter
;
// bound to m_planeSplitterDevice
127
ComPtr
<
ID3D11Device
>
m_planeSplitterDevice
;
// device m_planeSplitter was created for
128
129
ComPtr
<
ID3D11Device
>
m_d3d11on12Device
;
130
D3D12OutputTexturePool
m_d3d12OutputPool
;
// used with m_bridge
131
D3D12OutputTexturePool
m_d3d12OutputPool2
;
// used with m_bridge2
132
133
#
if
QT_CONFIG
(
opengl
)
134
QVideoFrameTexturesHandlesUPtr
importTextureOpenGL
(
QRhi
&
rhi
,
ID3D11Device
*
srcDevice
,
135
ID3D11DeviceContext
*
srcContext
,
136
const
ComPtr
<
ID3D11Texture2D
> &
texture
,
137
const
QSize
&
frameSize
,
138
ComPtr
<
ID3D11Texture2D
> &
interopTexSlot
);
139
void
releaseGLInterop
();
140
141
// OpenGL interop (WGL_NV_DX_interop2)
142
WglDxDeviceHandle
m_glInteropDevice
;
143
ComPtr
<
ID3D11Texture2D
>
m_glInteropTex
;
// cached non-shared texture; single-plane import
144
ComPtr
<
ID3D11Texture2D
>
m_glInteropTex2
;
// cached non-shared texture; second plane when split
145
std
::
unique_ptr
<
QObject
>
m_glCleanupContext
;
// context object for the cleanup connection
146
#
endif
147
};
148
149
}
// namespace QtMultimediaPrivate
150
151
QT_END_NAMESPACE
152
153
#
endif
// QWINDOWSD3D11RHITEXTUREIMPORTER_P_H
QtMultimediaPrivate::QWindowsD3D11RhiTextureImporter
Definition
qwindowsd3d11rhitextureimporter_p.h:68
QtMultimediaPrivate::impl
Definition
qaudiosystem_p.h:257
qtmultimedia
src
multimedia
windows
qwindowsd3d11rhitextureimporter_p.h
Generated on
for Qt by
1.16.1