aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc13
-rw-r--r--src/quick/scenegraph/qsgrhisupport.cpp17
-rw-r--r--src/quick/scenegraph/qsgrhisupport_p.h2
3 files changed, 27 insertions, 5 deletions
diff --git a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
index 864d90274c..e09c430e43 100644
--- a/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
+++ b/src/quick/doc/src/concepts/visualcanvas/scenegraph.qdoc
@@ -1016,6 +1016,14 @@ with multiple windows.
\li Where applicable (Vulkan, Direct3D), enables the graphics API implementation's debug
and/or validation layers, if available.
+ \row
+ \li \c QSG_RHI_PREFER_SOFTWARE_RENDERER
+ \li \c 1
+ \li 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, Direct3D or Vulkan), and is ignored
+ otherwise.
+
\endtable
Applications wishing to always run with a single given graphics API, can
@@ -1031,4 +1039,9 @@ with multiple windows.
equivalent in effect to running with both \c QSG_RHI and \c QSG_RHI_BACKEND
set.
+ All QRhi backends will choose the system default GPU adapter or physical
+ device, unless overridden by \c{QSG_RHI_PREFER_SOFTWARE_RENDERER} or a
+ backend-specific variable, such as, \c{QT_D3D_ADAPTER_INDEX} or
+ \c{QT_VK_PHYSICAL_DEVICE_INDEX}. No further adapter configurability is
+ provided at this time.
*/
diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp
index 2c5d8fb2ac..12c6742342 100644
--- a/src/quick/scenegraph/qsgrhisupport.cpp
+++ b/src/quick/scenegraph/qsgrhisupport.cpp
@@ -101,7 +101,8 @@ QSGRhiSupport::QSGRhiSupport()
m_enableRhi(false),
m_debugLayer(false),
m_profile(false),
- m_shaderEffectDebug(false)
+ m_shaderEffectDebug(false),
+ m_preferSoftwareRenderer(false)
{
}
@@ -140,7 +141,7 @@ void QSGRhiSupport::applySettings()
}
} else {
// check env.vars., fall back to platform-specific defaults when backend is not set
- m_enableRhi = qEnvironmentVariableIntValue("QSG_RHI");
+ m_enableRhi = uint(qEnvironmentVariableIntValue("QSG_RHI"));
const QByteArray rhiBackend = qgetenv("QSG_RHI_BACKEND");
if (rhiBackend == QByteArrayLiteral("gl")
|| rhiBackend == QByteArrayLiteral("gles2")
@@ -171,12 +172,14 @@ void QSGRhiSupport::applySettings()
return;
// validation layers (Vulkan) or debug layer (D3D)
- m_debugLayer = qEnvironmentVariableIntValue("QSG_RHI_DEBUG_LAYER");
+ m_debugLayer = uint(qEnvironmentVariableIntValue("QSG_RHI_DEBUG_LAYER"));
// EnableProfiling + DebugMarkers
- m_profile = qEnvironmentVariableIntValue("QSG_RHI_PROFILE");
+ m_profile = uint(qEnvironmentVariableIntValue("QSG_RHI_PROFILE"));
- m_shaderEffectDebug = qEnvironmentVariableIntValue("QSG_RHI_SHADEREFFECT_DEBUG");
+ m_shaderEffectDebug = uint(qEnvironmentVariableIntValue("QSG_RHI_SHADEREFFECT_DEBUG"));
+
+ m_preferSoftwareRenderer = uint(qEnvironmentVariableIntValue("QSG_RHI_PREFER_SOFTWARE_RENDERER"));
m_killDeviceFrameCount = qEnvironmentVariableIntValue("QSG_RHI_SIMULATE_DEVICE_LOSS");
if (m_killDeviceFrameCount > 0 && m_rhiBackend == QRhi::D3D11)
@@ -205,6 +208,8 @@ void QSGRhiSupport::applySettings()
qCDebug(QSG_LOG_INFO,
"Using QRhi with backend %s\n graphics API debug/validation layers: %d\n QRhi profiling and debug markers: %d",
backendName, m_debugLayer, m_profile);
+ if (m_preferSoftwareRenderer)
+ qCDebug(QSG_LOG_INFO, "Prioritizing software renderers");
}
QSGRhiSupport *QSGRhiSupport::staticInst()
@@ -463,6 +468,8 @@ QRhi *QSGRhiSupport::createRhi(QWindow *window, QOffscreenSurface *offscreenSurf
QRhi::Flags flags = 0;
if (isProfilingRequested())
flags |= QRhi::EnableProfiling | QRhi::EnableDebugMarkers;
+ if (isSoftwareRendererRequested())
+ flags |= QRhi::PreferSoftwareRenderer;
QRhi::Implementation backend = rhiBackend();
if (backend == QRhi::Null) {
diff --git a/src/quick/scenegraph/qsgrhisupport_p.h b/src/quick/scenegraph/qsgrhisupport_p.h
index 536efa55c3..d008ecd0af 100644
--- a/src/quick/scenegraph/qsgrhisupport_p.h
+++ b/src/quick/scenegraph/qsgrhisupport_p.h
@@ -114,6 +114,7 @@ public:
bool isDebugLayerRequested() const { return m_debugLayer; }
bool isProfilingRequested() const { return m_profile; }
bool isShaderEffectDebuggingRequested() const { return m_shaderEffectDebug; }
+ bool isSoftwareRendererRequested() const { return m_preferSoftwareRenderer; }
QSurface::SurfaceType windowSurfaceType() const;
@@ -144,6 +145,7 @@ private:
uint m_debugLayer : 1;
uint m_profile : 1;
uint m_shaderEffectDebug : 1;
+ uint m_preferSoftwareRenderer : 1;
};
// Sends QRhi resource statistics over a QTcpSocket. To be initialized by the