Scene Graph Adaptations¶
Scene Graph Adaptations in Qt Quick¶
Originally, Qt Quick always relied on OpenGL (OpenGL ES 2.0 or OpenGL 2.0) to parse the scene graph and render the results to a render target
From Qt 5.8 onwards, Qt Quick also supports rendering in software, with OpenVG , and with Direct3D 12. This is realized by having additional scene graph adaptations, either in form of plugins (d3d12, openvg) or built-in to the Qt Quick library (software). The default adaptation continues to rely directly on OpenGL.
From Qt 5.14 onwards, the default adaptation gains the option of rendering via a graphics abstraction layer, the Qt Rendering Hardware Interface (RHI), provided by the QtGui module. When enabled, no direct OpenGL calls are made. Rather, the scene graph renders by using the APIs provided by the abstraction layer, which is then translated into OpenGL, Vulkan, Metal, or Direct 3D calls. Shader handling is also unified by writing shader code once, compiling to SPIR-V , and then translating to the language appropriate for the various graphics APIs.
Switch Between Adaptations in Your Application¶
d3d12, the RHI-based renderer is not an additional adaptation, and is always built-in. As of Qt 5.14 it can be enabled by setting the environment variable
QSG_RHIto a non-zero value before starting the application, or via
setSceneGraphBackend()in combination with
GraphicsApi. When none of this is done, OpenGL is used directly like in previous versions.
Switching to a different adaptation can be achieved in two ways:
Use an environment variable - Set the
QT_QUICK_BACKENDor the legacy
QMLSCENE_DEVICEenvironment variable before launching applications.
Use a C++ API - Call
setSceneGraphBackend()early on in the application’s main() function.
The following backends are supported:
Default - Request with the
""string or a
GraphicsApienum value different than the ones listed below.
Software - Request with the
"software"string or the
Direct3D 12 - Request with the
"d3d12"string or the
OpenVG - Request with the
"openvg"string or the
To find out which backend is in use, you can enable basic scene graph information logging via the
QSG_INFOenvironment variable or the
qt.scenegraph.generallogging category. This results in some information being printed onto the debug output, during application startup.
In Qt builds with OpenGL disabled, the default adaptation is
software. This may change in future releases.
Typically, adaptations other than the default one come with a set of limitations as they are unlikely to provide a feature set that’s 100% compatible with OpenGL. However, these adaptations may provide their own specific advantages in certain areas. For more information on the various adaptations, refer to the sections below.
When using OpenGL directly, the default adaptation is capable of providing the full Qt Quick 2 feature set. For more details, see Default Adaptation .
When using OpenGL, Vulkan, Metal, or Direct 3D via the RHI, the default adaptation is capable of providing most features, including the full batching renderer described in Default Adaptation , but some additional features may not be available as of Qt 5.14.
The Software adaptation is an alternative renderer for Qt Quick 2 that uses the raster paint engine to render the contents of the scene graph. For more details, see Software Adaptation .
Direct3D 12 (experimental)¶
The Direct3D 12 adaptation is an alternative renderer for Qt Quick 2 when running on Windows 10, both for Win32 and UWP applications. For more details, see Direct3D 12 Adaptation .
© 2020 The Qt Company Ltd. Documentation contributions included herein are the copyrights of their respective owners. The documentation provided herein is licensed under the terms of the GNU Free Documentation License version 1.3 as published by the Free Software Foundation. Qt and respective logos are trademarks of The Qt Company Ltd. in Finland and/or other countries worldwide. All other trademarks are property of their respective owners.