diff options
author | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-09-07 19:23:09 +0200 |
---|---|---|
committer | Laszlo Agocs <laszlo.agocs@qt.io> | 2019-09-12 12:39:12 +0200 |
commit | f567129bb514b5856c7d1320cdc4dd5a84a5b6e3 (patch) | |
tree | 7e5209853f6877bb4ce7774053fe1a5148e11ddb /tests | |
parent | 08ad96404b4c915eece1a547bf12e91664e7cdff (diff) |
rhi: d3d11: Add the device lost testing machinery
The device can be lost when physically removing the graphics adapter,
disabling the driver (Device Manager), upgrading/uninstalling the
graphics driver, and when it is reset due to an error.
Some of these can (and should) be tested manually, but the last
one has a convenient, programmatic way of triggering: by triggering
the timeout detection and recovery (TDR) of WDDM. A compute shader
with an infinite loop should trigger this after 2 seconds by default.
All tests in tests/manual/rhi can now be started with a --curse <count>
argument where <count> specifies the number of frames to render before
breaking the device. Qt Quick will get an environment variable with
similar semantics in a separate patch.
Change-Id: I4b6f8d977a15b5b89d686b3973965df6435810ae
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/manual/rhi/shared/examplefw.h | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/tests/manual/rhi/shared/examplefw.h b/tests/manual/rhi/shared/examplefw.h index 1a29ef5f7e..8afacc074a 100644 --- a/tests/manual/rhi/shared/examplefw.h +++ b/tests/manual/rhi/shared/examplefw.h @@ -126,6 +126,7 @@ int sampleCount = 1; QRhiSwapChain::Flags scFlags = 0; QRhi::BeginFrameFlags beginFrameFlags = 0; QRhi::EndFrameFlags endFrameFlags = 0; +int framesUntilTdr = -1; class Window : public QWindow { @@ -278,6 +279,10 @@ void Window::init() if (graphicsApi == D3D11) { QRhiD3D11InitParams params; params.enableDebugLayer = true; + if (framesUntilTdr > 0) { + params.framesUntilKillingDeviceViaTdr = framesUntilTdr; + params.repeatDeviceKill = true; + } m_r = QRhi::create(QRhi::D3D11, ¶ms, rhiFlags); } #endif @@ -461,8 +466,13 @@ int main(int argc, char **argv) // Testing cleanup both with QWindow::close() (hitting X or Alt-F4) and // QCoreApplication::quit() (e.g. what a menu widget would do) is important. // Use this parameter for the latter. - QCommandLineOption sdOption({ "s", "self-destruct" }, QLatin1String("Self destruct after 5 seconds")); + QCommandLineOption sdOption({ "s", "self-destruct" }, QLatin1String("Self-destruct after 5 seconds.")); cmdLineParser.addOption(sdOption); + // Attempt testing device lost situations on D3D at least. + QCommandLineOption tdrOption(QLatin1String("curse"), QLatin1String("Curse the graphics device. " + "(generate a device reset every <count> frames when on D3D11)"), + QLatin1String("count")); + cmdLineParser.addOption(tdrOption); cmdLineParser.process(app); if (cmdLineParser.isSet(nullOption)) @@ -521,6 +531,9 @@ int main(int argc, char **argv) } #endif + if (cmdLineParser.isSet(tdrOption)) + framesUntilTdr = cmdLineParser.value(tdrOption).toInt(); + // Create and show the window. Window w; #if QT_CONFIG(vulkan) |