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
37QT_BEGIN_NAMESPACE
38
39class QRhi;
40
41namespace QtMultimediaPrivate {
42
43#if QT_CONFIG(opengl)
45{
46public:
47 WglDxDeviceDeleter() = default;
49 void operator()(HANDLE device) const noexcept
50 {
53 }
54
55private:
56 BOOL(WINAPI *m_closeFn)(HANDLE) = nullptr;
57};
58
60{
61 using Type = HANDLE;
62 static Type invalidValue() noexcept { return nullptr; }
63};
65#endif
66
67class Q_MULTIMEDIA_EXPORT QWindowsD3D11RhiTextureImporter
68{
69public:
72
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. */
80
81 /** 'pixelFormat' is only consulted on D3D12 and OpenGL, to route multi-plane textures
82 * through QWindowsD3D11PlaneSplitter. Returns null on failure. */
87
88private:
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.
93 {
94 public:
95 struct Texture
96 {
98 // Set while the handles of a frame use the texture.
100 };
101
103
104 private:
106 };
107
111 const QSize &frameSize,
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
130 D3D12OutputTexturePool m_d3d12OutputPool; // used with m_bridge
131 D3D12OutputTexturePool m_d3d12OutputPool2; // used with m_bridge2
132
133#if QT_CONFIG(opengl)
137 const QSize &frameSize,
139 void releaseGLInterop();
140
141 // OpenGL interop (WGL_NV_DX_interop2)
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
151QT_END_NAMESPACE
152
153#endif // QWINDOWSD3D11RHITEXTUREIMPORTER_P_H