Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
qquickgraphicsconfiguration.cpp
Go to the documentation of this file.
1// Copyright (C) 2020 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
5#include <QCoreApplication>
6#include <rhi/qrhi.h>
7
9
331
335void QQuickGraphicsConfiguration::detach()
336{
337 qAtomicDetach(d);
338}
339
348
357
366
383{
384#if QT_CONFIG(vulkan)
385 return QRhiVulkanInitParams::preferredInstanceExtensions();
386#else
387 return {};
388#endif
389}
390
402{
403 if (d->deviceExtensions != extensions) {
404 detach();
405 d->deviceExtensions = extensions;
406 }
407}
408
416
458
469
516
528
562
574
606
619
651
663
682
698
734{
735 if (d->pipelineCacheSaveFile != filename) {
736 detach();
737 d->pipelineCacheSaveFile = filename;
738 }
739}
740
750
794{
795 if (d->pipelineCacheLoadFile != filename) {
796 detach();
797 d->pipelineCacheLoadFile = filename;
798 }
799}
800
810
812 : ref(1)
813{
814 // Defaults based on env.vars. NB! many of these variables are documented
815 // and should be considered (semi-)public API. Changing the env.var. names
816 // is therefore not allowed.
817
818 flags = {};
819
820 static const bool useDepthBufferFor2D = qEnvironmentVariableIsEmpty("QSG_NO_DEPTH_BUFFER");
821 if (useDepthBufferFor2D)
823
824 static const bool enableDebugLayer = qEnvironmentVariableIntValue("QSG_RHI_DEBUG_LAYER");
825 if (enableDebugLayer)
827
828 static const bool enableProfilingRelated = qEnvironmentVariableIntValue("QSG_RHI_PROFILE");
829 if (enableProfilingRelated)
831
832 static const bool preferSoftwareDevice = qEnvironmentVariableIntValue("QSG_RHI_PREFER_SOFTWARE_RENDERER");
833 if (preferSoftwareDevice)
835
836 // here take the existing QOpenGL disk cache attribute and env.var. into account as well
837 static const bool autoPipelineCache = !QCoreApplication::instance()->testAttribute(Qt::AA_DisableShaderDiskCache)
838 && !qEnvironmentVariableIntValue("QT_DISABLE_SHADER_DISK_CACHE")
839 && !qEnvironmentVariableIntValue("QSG_RHI_DISABLE_DISK_CACHE");
840 if (autoPipelineCache)
842
843 static const QString pipelineCacheSaveFileEnv = qEnvironmentVariable("QSG_RHI_PIPELINE_CACHE_SAVE");
844 pipelineCacheSaveFile = pipelineCacheSaveFileEnv;
845
846 static const QString pipelineCacheLoadFileEnv = qEnvironmentVariable("QSG_RHI_PIPELINE_CACHE_LOAD");
847 pipelineCacheLoadFile = pipelineCacheLoadFileEnv;
848}
849
851 : ref(1),
852 deviceExtensions(other.deviceExtensions),
854 pipelineCacheSaveFile(other.pipelineCacheSaveFile),
855 pipelineCacheLoadFile(other.pipelineCacheLoadFile)
856{
857}
858
859#ifndef QT_NO_DEBUG_STREAM
861{
862 QDebugStateSaver saver(dbg);
864 dbg.nospace() << "QQuickGraphicsConfiguration("
865 << "flags=0x" << Qt::hex << cd->flags << Qt::dec
866 << " flag-isDepthBufferEnabledFor2D=" << config.isDepthBufferEnabledFor2D()
867 << " flag-isDebugLayerEnabled=" << config.isDebugLayerEnabled()
868 << " flag-isDebugMarkersEnabled=" << config.isDebugMarkersEnabled()
869 << " flag-prefersSoftwareDevice=" << config.prefersSoftwareDevice()
870 << " flag-isAutomaticPipelineCacheEnabled=" << config.isAutomaticPipelineCacheEnabled()
871 << " pipelineCacheSaveFile=" << cd->pipelineCacheSaveFile
872 << " piplineCacheLoadFile=" << cd->pipelineCacheLoadFile
873 << " extra-device-extension-requests=" << cd->deviceExtensions
874 << ')';
875 return dbg;
876}
877#endif // QT_NO_DEBUG_STREAM
878
bool ref() noexcept
bool deref() noexcept
\inmodule QtCore
static QCoreApplication * instance() noexcept
Returns a pointer to the application's QCoreApplication (or QGuiApplication/QApplication) instance.
\inmodule QtCore
\inmodule QtCore
static QQuickGraphicsConfigurationPrivate * get(QQuickGraphicsConfiguration *p)
QQuickGraphicsConfiguration controls lower level graphics settings for the QQuickWindow.
void setPreferSoftwareDevice(bool enable)
Requests choosing an adapter or physical device that uses software-based rasterization.
void setDepthBufferFor2D(bool enable)
Sets the usage of depth buffer for 2D content to enable.
void setPipelineCacheSaveFile(const QString &filename)
Sets the filename where the QQuickWindow is expected to store its graphics/compute pipeline cache con...
void setAutomaticPipelineCache(bool enable)
Changes the usage of the automatic pipeline cache based on enable.
void setDeviceExtensions(const QByteArrayList &extensions)
Sets the list of additional extensions to enable on the graphics device (such as, the VkDevice).
void setTimestamps(bool enable)
When enabled, GPU timing data is collected from command buffers on platforms and 3D APIs where this i...
void setPipelineCacheLoadFile(const QString &filename)
Sets the filename where the QQuickWindow is expected to load the initial contents of its graphics/com...
QQuickGraphicsConfiguration & operator=(const QQuickGraphicsConfiguration &other)
void setDebugLayer(bool enable)
Enables the graphics API implementation's debug or validation layers, if available.
static QByteArrayList preferredInstanceExtensions()
QQuickGraphicsConfiguration()
Constructs a default QQuickGraphicsConfiguration that does not specify any additional settings for th...
void setDebugMarkers(bool enable)
Where applicable, enable controls inserting debug markers and object names into the graphics command ...
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:129
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
QTextStream & dec(QTextStream &stream)
Calls QTextStream::setIntegerBase(10) on stream and returns stream.
@ AA_DisableShaderDiskCache
Definition qnamespace.h:462
QT_WARNING_POP void qAtomicAssign(T *&d, T *x)
This is a helper for the assignment operators of implicitly shared classes.
Definition qatomic.h:180
void qAtomicDetach(T *&d)
This is a helper for the detach method of implicitly shared classes.
Definition qatomic.h:199
EGLConfig config
GLbitfield flags
GLboolean enable
GLint ref
QDebug operator<<(QDebug dbg, const QQuickGraphicsConfiguration &config)
QString qEnvironmentVariable(const char *varName, const QString &defaultValue)
Q_CORE_EXPORT bool qEnvironmentVariableIsEmpty(const char *varName) noexcept
Q_CORE_EXPORT int qEnvironmentVariableIntValue(const char *varName, bool *ok=nullptr) noexcept
QSharedPointer< T > other(t)
[5]