From f567129bb514b5856c7d1320cdc4dd5a84a5b6e3 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Sat, 7 Sep 2019 19:23:09 +0200 Subject: rhi: d3d11: Add the device lost testing machinery MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 argument where 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 --- tests/manual/rhi/shared/examplefw.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'tests/manual/rhi/shared') 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 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) -- cgit v1.2.3