diff options
Diffstat (limited to 'src/quick/scenegraph/qsgrhisupport.cpp')
-rw-r--r-- | src/quick/scenegraph/qsgrhisupport.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index e050938cc9..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,18 @@ 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) + qDebug("Graphics device will be reset every %d frames", m_killDeviceFrameCount); const char *backendName = "unknown"; switch (m_rhiBackend) { @@ -201,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() @@ -459,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) { @@ -489,6 +500,10 @@ QRhi *QSGRhiSupport::createRhi(QWindow *window, QOffscreenSurface *offscreenSurf if (backend == QRhi::D3D11) { QRhiD3D11InitParams rhiParams; rhiParams.enableDebugLayer = isDebugLayerRequested(); + if (m_killDeviceFrameCount > 0) { + rhiParams.framesUntilKillingDeviceViaTdr = m_killDeviceFrameCount; + rhiParams.repeatDeviceKill = true; + } rhi = QRhi::create(backend, &rhiParams, flags); } #endif |