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
adaptations.qdoc
Go to the documentation of this file.
1
// Copyright (C) 2017 The Qt Company Ltd.
2
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GFDL-1.3-no-invariants-only
3
4
/*!
5
\title Scene Graph Adaptations
6
\page qtquick-visualcanvas-adaptations.html
7
8
\section1 Scene Graph Adaptations in Qt Quick
9
10
In Qt 5.0, Qt Quick always relied on OpenGL (OpenGL ES 2.0 or OpenGL 2.0) to
11
parse the scene graph and render the results to a render target.
12
13
From Qt 5.8 onwards, Qt Quick also supports rendering in software, and with
14
OpenVG. This is realized by having additional scene graph adaptations, either
15
in form of plugins (openvg) or built-in to the Qt Quick library
16
(software). The default adaptation continues to rely directly on OpenGL.
17
18
From Qt 5.14 onwards, the default adaptation gains the option of rendering via
19
a graphics abstraction layer, the Qt Rendering Hardware Interface (RHI),
20
provided by the \l [QtGui]{Qt GUI} module. When enabled, no direct OpenGL calls are made.
21
Rather, the scene graph renders by using the APIs provided by the abstraction
22
layer, which is then translated into OpenGL, Vulkan, Metal, or Direct 3D calls.
23
Shader handling is also unified by writing shader code once, compiling to
24
\l{https://www.khronos.org/spir/}{SPIR-V}, and then translating to the language
25
appropriate for the various graphics APIs.
26
27
Starting with Qt 6.0, the RHI-based rendering model is the default, and there is
28
no option to fall back to directly using OpenGL.
29
30
\target Switching Between the Adaptation Used by the Application
31
\section1 Switch Between Adaptations in Your Application
32
33
Unlike \c software, the RHI-based renderer is not an additional adaptation, and
34
is always built-in. As of Qt 6.0 it is always enabled. On platforms where
35
multiple graphics APIs are available, the scenegraph makes a platform-specific
36
choice. If this is not desired, applications can force a specified graphics API
37
by setting the environment variable \c{QSG_RHI_BACKEND} or via \l
38
QQuickWindow::setGraphicsApi() in combination with \l
39
QSGRendererInterface::GraphicsApi.
40
41
Switching to a different adaptation can be achieved in two ways:
42
43
\list
44
\li Use an environment variable - Set the \c{QT_QUICK_BACKEND} or the legacy
45
\c{QMLSCENE_DEVICE} environment variable before launching applications.
46
\li Use a C++ API - Call QQuickWindow::setSceneGraphBackend() early on in the application's
47
main() function.
48
\endlist
49
50
The following backends are supported:
51
52
\list
53
\li Default - Request with the \c{"rhi"} string or a QSGRendererInterface::GraphicsApi enum value
54
different than the ones listed below.
55
\li Software - Request with the \c{"software"} string or the QSGRendererInterface::Software
56
enum value.
57
\li OpenVG - Request with the \c{"openvg"} string or the QSGRendererInterface::OpenVG enum
58
value.
59
\endlist
60
61
To find out which backend is in use, you can enable basic scene graph information logging via the
62
\c{QSG_INFO} environment variable or the \c{qt.scenegraph.general} logging category. This results
63
in some information being printed onto the debug output, during application startup.
64
65
\note In Qt builds with both OpenGL and Vulkan disabled, the default adaptation
66
is \c software. This does not apply to Windows or \macos however, because these
67
platforms always have Direct 3D or Metal support, respectively, enabled.
68
69
\note Typically, adaptations other than the default one come with a set of
70
limitations as they are unlikely to provide a feature set that's 100%
71
compatible with OpenGL. However, these adaptations may provide their own
72
specific advantages in certain areas. For more information on the various
73
adaptations, refer to the sections below.
74
75
\section1 Default Adaptation
76
77
When using OpenGL directly, the default adaptation is capable of providing the
78
full Qt Quick 2 feature set. For more details, see
79
\l{qtquick-visualcanvas-scenegraph-renderer.html}{Default Adaptation}.
80
81
\section1 Software Adaptation
82
83
The Software adaptation is an alternative renderer for \l{Qt Quick} 2 that uses the raster paint
84
engine to render the contents of the scene graph. For more details, see
85
\l{qtquick-visualcanvas-adaptations-software.html}{Software Adaptation}.
86
87
\section1 OpenVG
88
89
The OpenVG adaptation is an alternative renderer for \l{Qt Quick} 2 that renders the contents of
90
the scene graph using OpenVG commands to provide hardware-accelerated 2D vector and raster
91
graphics. For more details, see
92
\l{qtquick-visualcanvas-adaptations-openvg.html}{OpenVG Adaptation}.
93
*/
94
95
96
/*!
97
\title Qt Quick Software Adaptation
98
\page qtquick-visualcanvas-adaptations-software.html
99
100
The Software adaptation is an alternative renderer for \l {Qt Quick} 2 that uses the Raster paint
101
engine to render the contents of the scene graph, instead of a hardware-accelerated 3D graphics API.
102
Consequently, some features and optimizations are not available. Most Qt Quick 2 applications can run
103
without any modification, but any attempts to use unsupported features are ignored.
104
By using the Software adaptation, it is possible to run Qt Quick 2 applications on hardware and
105
platforms that do not have \l{topics-graphics}{hardware-accelerated 3D graphics API} support.
106
107
The Software adaptation was previously known as the Qt Quick 2D Renderer. However, unlike the 2D
108
Renderer, this new, integrated version supports partial updates. This means that a full update
109
of the window or screen contents is now avoided; only the changed areas are flushed. Partial
110
updates can significantly improve performance for many applications. It is also possible to disable
111
this partial update behavior by setting the environment variable
112
\c{QSG_SOFTWARE_RENDERER_FORCE_PARTIAL_UPDATES=0}, though doing so will have a negative impact on
113
performance.
114
115
\section2 Shader Effects
116
117
ShaderEffect components in QtQuick 2 cannot be rendered by the Software adaptation.
118
119
\section2 Particle Effects
120
121
It is not possible to render particle effects with the Software adaptation. Whenever possible,
122
remove particles completely from the scene. Otherwise, they will still require some processing,
123
even though they are not visible.
124
125
\section2 Rendering Text
126
127
The text rendering with the Software adaptation is based on software rasterization and does not
128
respond as well to transformations such as scaling, compared to when using a hardware-accelerated
129
3D graphics API. The quality is similar to choosing \l [QML] {Text::renderType}{Text.NativeRendering}
130
with \l [QML] {Text} items.
131
132
133
\section2 High DPI
134
135
The Software adaptation supports high DPI displays, but it does not support performing partial updates
136
when the using fractional scaling. This means that when using a non-integer scaling factor, the partial
137
update optimization is disabled, and the entire window is redrawn on every frame. This can be overridden
138
by setting an environment variable to \c{QSG_SOFTWARE_RENDERER_FORCE_PARTIAL_UPDATES=1} which forces
139
the Software adaptation to use partial updates even when fractional scaling is in use. However, this
140
may result in artifacts when scaling is not an integer value, and it is not recommended to use this
141
without thorough testing.
142
143
*/
144
145
146
/*!
147
\title Qt Quick OpenVG Adaptation
148
\page qtquick-visualcanvas-adaptations-openvg.html
149
150
The OpenVG adaptation is an alternative renderer for \l{Qt Quick} 2 that renders the contents of
151
the scene graph using OpenVG commands to provide hardware accelerated 2D vector and raster
152
graphics. Much like the \l{qtquick-visualcanvas-adaptations-software.html}{Software Adaptation},
153
some features and optimizations are no longer available. Most Qt Quick 2 applications will run
154
without modification though any attempts to use unsupported features will be ignored.
155
156
\section2 EGL Requirement
157
158
Unlike the default OpenGL Renderer, there is no built-in support to acquire an OpenVG context.
159
This means that the renderer is responsible for requesting and managing the the current context.
160
To do this, you use EGL directly in the OpenVG renderer. Consequently, the OpenVG renderer can only
161
be used with platform plugins that support creating QWindows with support for
162
QSurfaceFormat::OpenVG. From this window, the renderer can get an EGLSurface which can then be used
163
with an EGLContext to render OpenVG content.
164
165
\section2 Renderer
166
167
The OpenVG Renderer uses the OpenVG API to send commands and data to a Vector GPU that renders the
168
scene graph in an accelerated manner, offloading graphics rendering from the CPU. Many operations
169
like the rendering of rectangles and font glyphs are ideal for OpenVG because they can be
170
represented as paths which are stroked and filled. Rendering scene graph items that would typically
171
involve textures are handled in the OpenVG renderer using VGImage. Additionally, when you render
172
to offscreen surfaces (like with Layers), the scene subtree is rendered to a VGImage which can be
173
reused in the scene.
174
175
\section2 Render Loop
176
177
The OpenVG Renderer mirrors the behavior of the Basic render loop and it runs all OpenVG commands
178
in a single thread.
179
180
For more information on render loops, see
181
\l{qtquick-visualcanvas-scenegraph.html}{Qt Quick Scene Graph}.
182
183
\section2 Shader Effects
184
185
ShaderEffect components in QtQuick 2 can't be rendered by the OpenVG adaptation. While it's
186
possible to use ShaderEffectSource and QML Item Layers (which are both offscreen surfaces), it's
187
not possible to apply shader effects to them via the ShaderEffect item. This is because OpenVG
188
lacks an API for applying per vertex and per fragment shader operations. However, you may be able
189
to take advantage of Image Filter operations in the OpenVG API to get effects that are similar to
190
what ShaderEffects provides in custom items. To integrate custom OpenVG rendering, use
191
QSGRenderNode in combination with QSGRendererInterface.
192
193
\section2 Particle Effects
194
195
It's not possible to render particle effects with the OpenVG adaptation. Whenever possible, remove
196
particles completely from the scene. Otherwise they'll still require some processing, even though
197
they are not visible.
198
199
\section2 Rendering Text
200
201
Text rendering with the OpenVG adaptation is based on rendering the glyph paths, and doesn't use
202
the distance fields technique, unlike with the OpenGL backend.
203
204
\section2 Perspective Transforms
205
206
The OpenVG API doesn't allow paths to be transformed with non-affine transforms, but it's
207
possible with Qt Quick. Consquently, when you render components using paths like Rectangles and
208
Text while applying perspective transforms, the OpenVG backend first renders to a VGImage before
209
applying transformations. This behavior uses more memory at runtime and takes more time; avoid it
210
if possible.
211
212
*/
qtdeclarative
src
quick
doc
src
concepts
visualcanvas
adaptations.qdoc
Generated on
for Qt by
1.14.0