![]() |
Qt 6.x
The Qt SDK
|
QQuickGraphicsConfiguration controls lower level graphics settings for the QQuickWindow. More...
#include <qquickgraphicsconfiguration.h>
Public Member Functions | |
QQuickGraphicsConfiguration () | |
Constructs a default QQuickGraphicsConfiguration that does not specify any additional settings for the scene graph to take into account. | |
~QQuickGraphicsConfiguration () | |
Destructor. | |
QQuickGraphicsConfiguration (const QQuickGraphicsConfiguration &other) | |
QQuickGraphicsConfiguration & | operator= (const QQuickGraphicsConfiguration &other) |
void | setDeviceExtensions (const QByteArrayList &extensions) |
Sets the list of additional extensions to enable on the graphics device (such as, the VkDevice ). | |
QByteArrayList | deviceExtensions () const |
void | setDepthBufferFor2D (bool enable) |
Sets the usage of depth buffer for 2D content to enable. | |
bool | isDepthBufferEnabledFor2D () const |
void | setDebugLayer (bool enable) |
Enables the graphics API implementation's debug or validation layers, if available. | |
bool | isDebugLayerEnabled () const |
void | setDebugMarkers (bool enable) |
Where applicable, enable controls inserting debug markers and object names into the graphics command stream. | |
bool | isDebugMarkersEnabled () const |
void | setTimestamps (bool enable) |
When enabled, GPU timing data is collected from command buffers on platforms and 3D APIs where this is supported. | |
bool | isTimestampsEnabled () const |
void | setPreferSoftwareDevice (bool enable) |
Requests choosing an adapter or physical device that uses software-based rasterization. | |
bool | prefersSoftwareDevice () const |
void | setAutomaticPipelineCache (bool enable) |
Changes the usage of the automatic pipeline cache based on enable. | |
bool | isAutomaticPipelineCacheEnabled () const |
void | setPipelineCacheSaveFile (const QString &filename) |
Sets the filename where the QQuickWindow is expected to store its graphics/compute pipeline cache contents. | |
QString | pipelineCacheSaveFile () const |
void | setPipelineCacheLoadFile (const QString &filename) |
Sets the filename where the QQuickWindow is expected to load the initial contents of its graphics/compute pipeline cache from. | |
QString | pipelineCacheLoadFile () const |
void | setHdr (bool enable) |
bool | isHdrEnabled () const |
Static Public Member Functions | |
static QByteArrayList | preferredInstanceExtensions () |
Friends | |
class | QQuickGraphicsConfigurationPrivate |
Q_QUICK_EXPORT QDebug | operator<< (QDebug dbg, const QQuickGraphicsConfiguration &config) |
QQuickGraphicsConfiguration controls lower level graphics settings for the QQuickWindow.
The QQuickGraphicsConfiguration class is a container for low-level graphics settings that can affect how the underlying graphics API, such as Vulkan, is initialized by the Qt Quick scene graph. It can also control certain aspects of the scene graph renderer.
Definition at line 15 of file qquickgraphicsconfiguration.h.
QQuickGraphicsConfiguration::QQuickGraphicsConfiguration | ( | ) |
Constructs a default QQuickGraphicsConfiguration that does not specify any additional settings for the scene graph to take into account.
Definition at line 324 of file qquickgraphicsconfiguration.cpp.
QQuickGraphicsConfiguration::~QQuickGraphicsConfiguration | ( | ) |
Destructor.
Definition at line 358 of file qquickgraphicsconfiguration.cpp.
References QBasicAtomicInteger< T >::deref(), and QQuickGraphicsConfigurationPrivate::ref.
QQuickGraphicsConfiguration::QQuickGraphicsConfiguration | ( | const QQuickGraphicsConfiguration & | other | ) |
Definition at line 340 of file qquickgraphicsconfiguration.cpp.
References QBasicAtomicInteger< T >::ref(), and QQuickGraphicsConfigurationPrivate::ref.
QByteArrayList QQuickGraphicsConfiguration::deviceExtensions | ( | ) | const |
Definition at line 409 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::deviceExtensions.
Referenced by QSGRhiSupport::createRhi().
bool QQuickGraphicsConfiguration::isAutomaticPipelineCacheEnabled | ( | ) | const |
By default this is true, unless certain application attributes or environment variables are set. See \l{The Automatic Pipeline Cache} for more information.
Definition at line 688 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::AutoPipelineCache, and QQuickGraphicsConfigurationPrivate::flags.
Referenced by QSGRhiSupport::createRhi().
bool QQuickGraphicsConfiguration::isDebugLayerEnabled | ( | ) | const |
By default the value is false.
Definition at line 521 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::EnableDebugLayer, and QQuickGraphicsConfigurationPrivate::flags.
Referenced by QSGRhiSupport::createRhi(), and QQuickWidgetPrivate::rhiConfig().
bool QQuickGraphicsConfiguration::isDebugMarkersEnabled | ( | ) | const |
By default the value is false.
Definition at line 567 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::EnableDebugMarkers, and QQuickGraphicsConfigurationPrivate::flags.
Referenced by QSGRhiSupport::createRhi().
bool QQuickGraphicsConfiguration::isDepthBufferEnabledFor2D | ( | ) | const |
By default the value is true, unless the {QSG_NO_DEPTH_BUFFER} environment variable is set.
Definition at line 462 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::flags, and QQuickGraphicsConfigurationPrivate::UseDepthBufferFor2D.
Referenced by QQuickWindowPrivate::syncSceneGraph().
bool QQuickGraphicsConfiguration::isHdrEnabled | ( | ) | const |
By default the value is false.
true
merely indicates the application's request.Definition at line 849 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::EnableHdr, and QQuickGraphicsConfigurationPrivate::flags.
bool QQuickGraphicsConfiguration::isTimestampsEnabled | ( | ) | const |
By default the value is false.
Definition at line 609 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::EnableTimestamps, and QQuickGraphicsConfigurationPrivate::flags.
Referenced by QSGRhiSupport::createRhi(), QSGGuiThreadRenderLoop::renderWindow(), and QSGRenderThread::syncAndRender().
QQuickGraphicsConfiguration & QQuickGraphicsConfiguration::operator= | ( | const QQuickGraphicsConfiguration & | other | ) |
Definition at line 349 of file qquickgraphicsconfiguration.cpp.
References other(), and qAtomicAssign().
QString QQuickGraphicsConfiguration::pipelineCacheLoadFile | ( | ) | const |
By default the value is an empty string.
Definition at line 800 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::pipelineCacheLoadFile.
QString QQuickGraphicsConfiguration::pipelineCacheSaveFile | ( | ) | const |
By default the value is an empty string.
Definition at line 740 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::pipelineCacheSaveFile.
Referenced by QSGRhiSupport::createRhi().
|
static |
In most cases Qt Quick is responsible for creating a QVulkanInstance. This function is not relevant then. On the other hand, when using QQuickRenderControl in combination with Vulkan-based rendering, it is the application's responsibility to create a QVulkanInstance and associate it with the (offscreen) QQuickWindow. In this case, it is expected that the application queries the list of instance extensions to enable, and passes them to QVulkanInstance::setExtensions() before calling QVulkanInstance::create().
Definition at line 379 of file qquickgraphicsconfiguration.cpp.
bool QQuickGraphicsConfiguration::prefersSoftwareDevice | ( | ) | const |
By default the value is false.
Definition at line 653 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::flags, and QQuickGraphicsConfigurationPrivate::PreferSoftwareDevice.
Referenced by QSGRhiSupport::createRhi().
void QQuickGraphicsConfiguration::setAutomaticPipelineCache | ( | bool | enable | ) |
Changes the usage of the automatic pipeline cache based on enable.
The default value is true, unless certain application attributes or environment variables are set. See \l{The Automatic Pipeline Cache} for more information.
Definition at line 669 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::AutoPipelineCache, and QQuickGraphicsConfigurationPrivate::flags.
void QQuickGraphicsConfiguration::setDebugLayer | ( | bool | enable | ) |
Enables the graphics API implementation's debug or validation layers, if available.
In practice this is supported with Vulkan and Direct 3D 11, assuming the necessary support (validation layers, Windows SDK) is installed and available at runtime. When enable is true, Qt will attempt to enable the standard validation layer on the VkInstance, or set {D3D11_CREATE_DEVICE_DEBUG} on the graphics device.
For Metal on \macos, set the environment variable {METAL_DEVICE_WRAPPER_TYPE=1} instead before launching the application.
Calling this function with enable set to true is equivalent to setting the environment variable {QSG_RHI_DEBUG_LAYER} to a non-zero value.
The default value is false.
Definition at line 506 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::EnableDebugLayer, and QQuickGraphicsConfigurationPrivate::flags.
void QQuickGraphicsConfiguration::setDebugMarkers | ( | bool | enable | ) |
Where applicable, enable controls inserting debug markers and object names into the graphics command stream.
Some frameworks, such as Qt Quick 3D, have the ability to annotate the graphics objects they create (buffers, textures) with names and also indicate the beginning and end of render passes in the command buffer. These are then visible in frame captures made with tools like \l{https://renderdoc.org/}{RenderDoc} or XCode.
Graphics APIs where this can be expected to be supported are Vulkan (if VK_EXT_debug_utils is available), Direct 3D 11, and Metal.
Calling this function with enable set to true is equivalent to setting the environment variable {QSG_RHI_PROFILE} to a non-zero value.
The default value is false.
Definition at line 552 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::EnableDebugMarkers, and QQuickGraphicsConfigurationPrivate::flags.
void QQuickGraphicsConfiguration::setDepthBufferFor2D | ( | bool | enable | ) |
Sets the usage of depth buffer for 2D content to enable.
When disabled, the Qt Quick scene graph never writes into the depth buffer.
By default the value is true, unless the {QSG_NO_DEPTH_BUFFER} environment variable is set.
The default value of true is the most optimal setting for the vast majority of scenes. Disabling depth buffer usage reduces the efficiency of the scene graph's batching.
There are cases however, when allowing the 2D content write to the depth buffer is not ideal. Consider a 3D scene as an "overlay" on top the 2D scene, rendered via Qt Quick 3D using a \l View3D with \l{View3D::renderMode}{renderMode} set to Overlay
. In this case, having the depth buffer filled by 2D content can cause unexpected results. This is because the way the 2D scene graph renderer generates and handles depth values is not necessarily compatible with how a 3D scene works. This may end up in depth value clashes, collisions, and unexpected depth test failures. Therefore, the robust approach here is to call this function with enable set to false, and disable depth buffer writes for the 2D content in the QQuickWindow.
{QSG_NO_DEPTH_BUFFER} environment variable. This flag does not control the depth-stencil buffers' presence. It is rather relevant for the rendering pipeline. To force not having depth/stencil attachments at all, set
{QSG_NO_DEPTH_BUFFER} and
{QSG_NO_STENCIL_BUFFER}. Be aware however that such a QQuickWindow, and any Item layers in it, may then become incompatible with items, such as View3D with certain operating modes, because 3D content requires a depth buffer. Calling this function is always safe, but can mean that resources, such as depth buffers, are created even though they are not actively used. Definition at line 448 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::flags, and QQuickGraphicsConfigurationPrivate::UseDepthBufferFor2D.
void QQuickGraphicsConfiguration::setDeviceExtensions | ( | const QByteArrayList & | extensions | ) |
Sets the list of additional extensions to enable on the graphics device (such as, the VkDevice
).
When rendering with a graphics API where the concept is not applicable, extensions will be ignored.
Definition at line 398 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::deviceExtensions.
void QQuickGraphicsConfiguration::setHdr | ( | bool | enable | ) |
When enabled, and the platform and the underlying 3D API supports it, the window will be using high/extended dynamic range rendering. This implies that the display on which the window is opened has HDR output enabled in the windowing system.
If the request cannot be fulfilled, it is gracefully ignored and the window is created with the normal standard dynamic range.
By default the value is false
.
To determine what color space and color buffer format got enabled, query the \l{QQuickWindow::swapChain()}{swapchain} from the window once the \l{QQuickWindow::sceneGraphInitialized()}{scene graph has initialized}, and inspect its \l{QRhiSwapChain::format()}{format}.
Definition at line 829 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::EnableHdr, and QQuickGraphicsConfigurationPrivate::flags.
Sets the filename where the QQuickWindow is expected to load the initial contents of its graphics/compute pipeline cache from.
The default value is empty, which means pipeline cache loading is disabled.
See \l{Pipeline Cache Save and Load} for a discussion on pipeline caches.
Persistently storing the pipeline cache can lead to performance improvements in future runs of the application since expensive shader compilation and pipeline construction steps may be avoided.
If and when the loading of the file's contents happens is not defined, apart from that it will happen at some point during the initialization of the scenegraph of the QQuickWindow. Therefore, the file must continue to exist after calling this function. QQuickGraphicsConfiguration only stores the filename, it cannot perform any actual I/O and graphics operations on its own. The real work is going to happen later on, possibly on another thread.
When running with a graphics API where retrieving and reloading the pipeline cache (or shader/program binaries) is not applicable or not supported, calling this function has no effect.
Calling this function is mostly equivalent to setting the environment variable {QSG_RHI_PIPELINE_CACHE_LOAD} to filename, with one important difference: this function controls the pipeline cache storage for the associated QQuickWindow only. Applications with multiple QQuickWindow or QQuickView instances can therefore store and later reload the cache contents via files dedicated to each window. The environment variable does not allow this.
Definition at line 787 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::pipelineCacheLoadFile.
Sets the filename where the QQuickWindow is expected to store its graphics/compute pipeline cache contents.
The default value is empty, which means pipeline cache loading is disabled.
See \l{Pipeline Cache Save and Load} for a discussion on pipeline caches.
Persistently storing the pipeline cache can lead to performance improvements in future runs of the application since expensive shader compilation and pipeline construction steps may be avoided.
If and when the writing of the file happens is not defined. It will likely happen at some point when tearing down the scenegraph due to closing the window. Therefore, applications should not assume availability of the file until the QQuickWindow is fully destructed. QQuickGraphicsConfiguration only stores the filename, it does not perform any actual I/O and graphics operations on its own.
When running with a graphics API where retrieving the pipeline cache (or shader/program binaries) is not applicable or not supported, calling this function has no effect.
Calling this function is mostly equivalent to setting the environment variable {QSG_RHI_PIPELINE_CACHE_SAVE} to filename, with one important difference: this function controls the pipeline cache storage for the associated QQuickWindow only. Applications with multiple QQuickWindow or QQuickView instances can therefore store and later reload the cache contents via files dedicated to each window. The environment variable does not allow this.
Definition at line 727 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::pipelineCacheSaveFile.
void QQuickGraphicsConfiguration::setPreferSoftwareDevice | ( | bool | enable | ) |
Requests choosing an adapter or physical device that uses software-based rasterization.
Applicable only when the underlying API has support for enumerating adapters (for example, Direct 3D or Vulkan), and is ignored otherwise.
If the graphics API implementation has no such graphics adapter or physical device available, the request is ignored. With Direct 3D it can be expected that a \l{https://docs.microsoft.com/en-us/windows/win32/direct3darticles/directx-warp}{WARP}-based rasterizer is always available. With Vulkan, the flag only has an effect if Mesa's lavapipe
, or some other physical device reporting {VK_PHYSICAL_DEVICE_TYPE_CPU} is available.
Calling this function with enable set to true is equivalent to setting the environment variable {QSG_RHI_PREFER_SOFTWARE_RENDERER} to a non-zero value.
The default value is false.
Definition at line 638 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::flags, and QQuickGraphicsConfigurationPrivate::PreferSoftwareDevice.
void QQuickGraphicsConfiguration::setTimestamps | ( | bool | enable | ) |
When enabled, GPU timing data is collected from command buffers on platforms and 3D APIs where this is supported.
This data is then printed in the renderer logs that can be enabled via {QSG_RENDER_TIMING} environment variable or logging categories such as
{qt.scenegraph.time.renderloop}, and may also be made visible to other modules, such as Qt Quick 3D's \l DebugView item.
By default this is disabled, because collecting the data may involve additional work, such as inserting timestamp queries in the command stream, depending on the underlying graphics API. To enable, either call this function with enable set to true, or set the {QSG_RHI_PROFILE} environment variable to a non-zero value.
Graphics APIs where this can be expected to be supported are Direct 3D 11, Vulkan, and Metal.
Definition at line 593 of file qquickgraphicsconfiguration.cpp.
References QQuickGraphicsConfigurationPrivate::EnableTimestamps, and QQuickGraphicsConfigurationPrivate::flags.
|
friend |
Definition at line 907 of file qquickgraphicsconfiguration.cpp.
|
friend |
Definition at line 58 of file qquickgraphicsconfiguration.h.