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
qwindowsd3d11testdevicecontext_p.h
Go to the documentation of this file.
1
// Copyright (C) 2025 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only
3
4
#
ifndef
QWINDOWSD3D11TESTDEVICECONTEXT_P_H
5
#
define
QWINDOWSD3D11TESTDEVICECONTEXT_P_H
6
7
//
8
// W A R N I N G
9
// -------------
10
//
11
// This file is not part of the Qt API. It exists purely as an
12
// implementation detail. This header file may change from version to
13
// version without notice, or even be removed.
14
//
15
// We mean it.
16
//
17
18
#
include
<
QtCore
/
qbytearray
.
h
>
19
#
include
<
QtCore
/
qbytearrayview
.
h
>
20
#
include
<
QtCore
/
qsize
.
h
>
21
#
include
<
QtCore
/
private
/
qcomptr_p
.
h
>
22
#
include
<
QtCore
/
private
/
qexpected_p
.
h
>
23
#
include
<
QtGui
/
qcolor
.
h
>
24
25
#
include
<
vector
>
26
27
#
include
<
d3d11_1
.
h
>
28
29
QT_BEGIN_NAMESPACE
30
class
QRhi;
31
QT_END_NAMESPACE
32
33
template
<
typename
T>
34
using
ComResult = q23::expected<T, HRESULT>;
35
36
// Shared D3D11 device fixture for Windows-only multimedia unit tests.
37
struct
QWindowsD3D11TestDeviceContext
38
{
39
ComPtr
<
ID3D11Device1
>
device
;
40
ComPtr
<
ID3D11DeviceContext
>
context
;
41
42
ComResult
<
QColor
>
getFirstPixelColor
(
const
ComPtr<ID3D11Texture2D> &texture)
const
;
43
44
// Like getFirstPixelColor, but interprets the pixel bytes in B,G,R,A order (for
45
// DXGI_FORMAT_B8G8R8A8_UNORM textures).
46
ComResult
<
QColor
>
getFirstPixelColorBGRA
(
const
ComPtr<ID3D11Texture2D> &texture)
const
;
47
48
ComResult
<
ComPtr
<
ID3D11Texture2D
>>
createTextureArray
(QSize size,
49
const
std::vector<QColor> &colors)
const
;
50
51
bool
isTextureFormatSupported
(DXGI_FORMAT format)
const
;
52
53
// Creates an uninitialized single-plane NV12 texture, e.g. for structural (plane
54
// count/size/format) tests that don't need to verify pixel contents.
55
ComResult
<
ComPtr
<
ID3D11Texture2D
>>
createNV12Texture
(QSize size)
const
;
56
57
// Fills an NV12 texture's luma plane with lumaValue and its interleaved chroma plane with
58
// (chromaUValue, chromaVValue), e.g. for pixel round-trip tests. If texture is a texture
59
// array (e.g. a pooled decoder surface), arraySlice selects which slice to fill.
60
HRESULT
fillNV12Texture
(
const
ComPtr<ID3D11Texture2D> &texture, QSize size, quint8 lumaValue,
61
quint8 chromaUValue, quint8 chromaVValue, UINT arraySlice = 0)
const
;
62
63
// Creates a single-plane NV12 texture with a uniform luma/chroma value, for tests that
64
// verify actual color conversion.
65
ComResult
<
ComPtr
<
ID3D11Texture2D
>>
66
createFilledNV12Texture
(QSize size, quint8 lumaValue, quint8 chromaU, quint8 chromaV)
const
;
67
68
// Same as createNV12Texture, but for a 10-bit P010 surface.
69
ComResult
<
ComPtr
<
ID3D11Texture2D
>>
createP010Texture
(QSize size)
const
;
70
71
// Same as fillNV12Texture, but for a 10-bit P010 surface: each 16-bit sample holds its value
72
// left-shifted into the high bits (FFmpeg's P010 convention).
73
HRESULT
fillP010Texture
(
const
ComPtr<ID3D11Texture2D> &texture, QSize size, quint16 lumaValue,
74
quint16 chromaUValue, quint16 chromaVValue, UINT arraySlice = 0)
const
;
75
76
// Creates an uninitialized single-plane texture in the given (non-planar) format, e.g. for
77
// structural tests of a packed hw pixel format.
78
ComResult
<
ComPtr
<
ID3D11Texture2D
>>
createSinglePlaneTexture
(QSize size,
79
DXGI_FORMAT format)
const
;
80
81
// Fills a single-plane texture uniformly by repeating texel across every pixel.
82
HRESULT
fillSinglePlaneTexture
(
const
ComPtr<ID3D11Texture2D> &texture, QSize size,
83
QByteArrayView texel, UINT arraySlice = 0)
const
;
84
85
// Reads back "height" rows of "width" texels ("texelSize" bytes each), tightly packed (row
86
// padding from the texture's native row pitch is stripped), starting "rowOffset" rows into
87
// the given array slice. Suitable for verifying any plane of any pixel format, e.g. the
88
// second (chroma) plane of a planar format by passing rowOffset = the first plane's height.
89
ComResult
<
QByteArray
>
readPlaneRows
(
const
ComPtr<ID3D11Texture2D> &texture,
int
rowOffset,
90
int
width,
int
height,
int
texelSize,
91
UINT arraySlice = 0)
const
;
92
93
private
:
94
// Function to set the pixels of an ID3D11Texture2D texture to red
95
HRESULT fillTextureWithColors(
const
ComPtr<ID3D11Texture2D> &texture,
96
const
std::vector<QColor> &colors)
const
;
97
98
// Creates a single-slice staging texture with the given CPU access, holding a copy of
99
// 'arraySlice' of 'texture'. Only that slice is copied: copying a whole multi-slice planar
100
// texture array created with D3D11_BIND_DECODER, like FFmpeg's decoder pool, removes the
101
// device on some drivers (seen on AMD).
102
ComResult<ComPtr<ID3D11Texture2D>>
103
createStagingSliceCopy(
const
ComPtr<ID3D11Texture2D> &texture, UINT arraySlice,
104
UINT cpuAccessFlags)
const
;
105
};
106
107
// Creates a device context using a hardware D3D11 adapter.
108
ComResult
<
QWindowsD3D11TestDeviceContext
>
createD3D11TestDeviceContext
();
109
110
// Creates a device context using the software (WARP) D3D11 adapter, e.g. to test behavior
111
// with a QRhi that reports QRhiDriverInfo::CpuDevice.
112
ComResult
<
QWindowsD3D11TestDeviceContext
>
createWarpD3D11TestDeviceContext
();
113
114
// Get QWindowsD3D11TestDeviceContext from QRhi instance
115
ComResult
<
QWindowsD3D11TestDeviceContext
>
wrapRhiD3D11Device
(QRhi &rhi);
116
117
#
endif
// QWINDOWSD3D11TESTDEVICECONTEXT_P_H
std
[33]
Definition
src_corelib_tools_qhash.cpp:421
wrapRhiD3D11Device
ComResult< QWindowsD3D11TestDeviceContext > wrapRhiD3D11Device(QRhi &rhi)
Definition
qwindowsd3d11testdevicecontext.cpp:531
createD3D11TestDeviceContext
ComResult< QWindowsD3D11TestDeviceContext > createD3D11TestDeviceContext()
Definition
qwindowsd3d11testdevicecontext.cpp:512
createD3D11TestDeviceContextImpl
static ComResult< QWindowsD3D11TestDeviceContext > createD3D11TestDeviceContextImpl(D3D_DRIVER_TYPE driverType, UINT flags)
Definition
qwindowsd3d11testdevicecontext.cpp:491
createWarpD3D11TestDeviceContext
ComResult< QWindowsD3D11TestDeviceContext > createWarpD3D11TestDeviceContext()
Definition
qwindowsd3d11testdevicecontext.cpp:522
QWindowsD3D11TestDeviceContext
Definition
qwindowsd3d11testdevicecontext_p.h:38
QWindowsD3D11TestDeviceContext::createSinglePlaneTexture
ComResult< ComPtr< ID3D11Texture2D > > createSinglePlaneTexture(QSize size, DXGI_FORMAT format) const
Definition
qwindowsd3d11testdevicecontext.cpp:318
QWindowsD3D11TestDeviceContext::device
ComPtr< ID3D11Device1 > device
Definition
qwindowsd3d11testdevicecontext_p.h:39
QWindowsD3D11TestDeviceContext::createFilledNV12Texture
ComResult< ComPtr< ID3D11Texture2D > > createFilledNV12Texture(QSize size, quint8 lumaValue, quint8 chromaU, quint8 chromaV) const
Definition
qwindowsd3d11testdevicecontext.cpp:227
QWindowsD3D11TestDeviceContext::createNV12Texture
ComResult< ComPtr< ID3D11Texture2D > > createNV12Texture(QSize size) const
Definition
qwindowsd3d11testdevicecontext.cpp:152
QWindowsD3D11TestDeviceContext::context
ComPtr< ID3D11DeviceContext > context
Definition
qwindowsd3d11testdevicecontext_p.h:40
QWindowsD3D11TestDeviceContext::isTextureFormatSupported
bool isTextureFormatSupported(DXGI_FORMAT format) const
Definition
qwindowsd3d11testdevicecontext.cpp:138
QWindowsD3D11TestDeviceContext::fillNV12Texture
HRESULT fillNV12Texture(const ComPtr< ID3D11Texture2D > &texture, QSize size, quint8 lumaValue, quint8 chromaUValue, quint8 chromaVValue, UINT arraySlice=0) const
Definition
qwindowsd3d11testdevicecontext.cpp:176
QWindowsD3D11TestDeviceContext::getFirstPixelColorBGRA
ComResult< QColor > getFirstPixelColorBGRA(const ComPtr< ID3D11Texture2D > &texture) const
Definition
qwindowsd3d11testdevicecontext.cpp:73
QWindowsD3D11TestDeviceContext::createP010Texture
ComResult< ComPtr< ID3D11Texture2D > > createP010Texture(QSize size) const
Definition
qwindowsd3d11testdevicecontext.cpp:242
QWindowsD3D11TestDeviceContext::readPlaneRows
ComResult< QByteArray > readPlaneRows(const ComPtr< ID3D11Texture2D > &texture, int rowOffset, int width, int height, int texelSize, UINT arraySlice=0) const
Definition
qwindowsd3d11testdevicecontext.cpp:376
QWindowsD3D11TestDeviceContext::fillP010Texture
HRESULT fillP010Texture(const ComPtr< ID3D11Texture2D > &texture, QSize size, quint16 lumaValue, quint16 chromaUValue, quint16 chromaVValue, UINT arraySlice=0) const
Definition
qwindowsd3d11testdevicecontext.cpp:266
QWindowsD3D11TestDeviceContext::createTextureArray
ComResult< ComPtr< ID3D11Texture2D > > createTextureArray(QSize size, const std::vector< QColor > &colors) const
Definition
qwindowsd3d11testdevicecontext.cpp:106
QWindowsD3D11TestDeviceContext::fillSinglePlaneTexture
HRESULT fillSinglePlaneTexture(const ComPtr< ID3D11Texture2D > &texture, QSize size, QByteArrayView texel, UINT arraySlice=0) const
Definition
qwindowsd3d11testdevicecontext.cpp:343
QWindowsD3D11TestDeviceContext::getFirstPixelColor
ComResult< QColor > getFirstPixelColor(const ComPtr< ID3D11Texture2D > &texture) const
Definition
qwindowsd3d11testdevicecontext.cpp:28
qtmultimedia
src
multimediatestlib
windows
qwindowsd3d11testdevicecontext_p.h
Generated on
for Qt by
1.18.0