aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLaszlo Agocs <laszlo.agocs@qt.io>2019-09-07 21:03:53 +0200
committerLaszlo Agocs <laszlo.agocs@qt.io>2019-09-23 12:50:25 +0200
commit67ce1dd81014836aa8b900fd039adfc7c63414b5 (patch)
tree077321b519f0616961bb0c3bbd77bcf70333a778
parent18955f3c89443d13a0b6dfa8056df1d38d5bbff6 (diff)
Add an env var to periodically kill the device on d3d
...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 <christian.stromme@qt.io>
-rw-r--r--src/quick/scenegraph/qsgrhisupport.cpp8
-rw-r--r--src/quick/scenegraph/qsgrhisupport_p.h1
2 files changed, 9 insertions, 0 deletions
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
diff --git a/src/quick/scenegraph/qsgrhisupport_p.h b/src/quick/scenegraph/qsgrhisupport_p.h
index f2d5837bba..536efa55c3 100644
--- a/src/quick/scenegraph/qsgrhisupport_p.h
+++ b/src/quick/scenegraph/qsgrhisupport_p.h
@@ -138,6 +138,7 @@ private:
uint rhi : 1;
} m_requested;
QRhi::Implementation m_rhiBackend = QRhi::Null;
+ int m_killDeviceFrameCount;
uint m_set : 1;
uint m_enableRhi : 1;
uint m_debugLayer : 1;