From 67ce1dd81014836aa8b900fd039adfc7c63414b5 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sat, 7 Sep 2019 21:03:53 +0200 Subject: Add an env var to periodically kill the device on d3d MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ...in order to test the handling of losing the device. The D3D11 backend of QRhi provides a convenient way to test this. Hook it up to a QSG_RHI_SIMULATE_DEVICE_LOSS environment variable. The value is the number of frames to wait before breaking the ID3D11Device. We cannot currently recover from a device loss. Hence the importance of being able to test in a simple way. The rhi code path needs to be brought up to the level of the direct OpenGL path in this respect, in separate patches. Change-Id: I66d6315dc60a9673903da9bed36de0cdd115f4a7 Reviewed-by: Christian Strømme --- src/quick/scenegraph/qsgrhisupport.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'src/quick/scenegraph/qsgrhisupport.cpp') diff --git a/src/quick/scenegraph/qsgrhisupport.cpp b/src/quick/scenegraph/qsgrhisupport.cpp index e050938cc9..2c5d8fb2ac 100644 --- a/src/quick/scenegraph/qsgrhisupport.cpp +++ b/src/quick/scenegraph/qsgrhisupport.cpp @@ -178,6 +178,10 @@ void QSGRhiSupport::applySettings() m_shaderEffectDebug = qEnvironmentVariableIntValue("QSG_RHI_SHADEREFFECT_DEBUG"); + 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) { case QRhi::Null: @@ -489,6 +493,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 -- cgit v1.2.3