diff --git a/src/gui/rhi/qrhi.cpp b/src/gui/rhi/qrhi.cpp index 0728d7824d6..67b8d2d134a 100644 --- a/src/gui/rhi/qrhi.cpp +++ b/src/gui/rhi/qrhi.cpp @@ -665,6 +665,17 @@ Q_LOGGING_CATEGORY(QRHI_LOG_INFO, "qt.rhi.general") mechanisms for shader/program binaries provided by Qt. Writing to those may get disabled whenever this flag is set since storing program binaries to multiple caches is not sensible. + + \value SuppressSmokeTestWarnings Indicates that, with backends where this + is relevant, certain, non-fatal QRhi::create() failures should not + produce qWarning() calls. For example, with D3D11, passing this flag + makes a number of warning messages (that appear due to QRhi::create() + failing) to become categorized debug prints instead under the commonly used + \c{qt.rhi.general} logging category. This can be used by engines, such as + Qt Quick, that feature fallback logic, i.e. they retry calling create() + with a different set of flags (such as, \l PreferSoftwareRenderer), in order + to hide the unconditional warnings from the output that would be printed + when the first create() attempt had failed. */ /*! diff --git a/src/gui/rhi/qrhi.h b/src/gui/rhi/qrhi.h index 770233bb519..f1620c11fab 100644 --- a/src/gui/rhi/qrhi.h +++ b/src/gui/rhi/qrhi.h @@ -1787,7 +1787,8 @@ public: EnableDebugMarkers = 1 << 0, PreferSoftwareRenderer = 1 << 1, EnablePipelineCacheDataSave = 1 << 2, - EnableTimestamps = 1 << 3 + EnableTimestamps = 1 << 3, + SuppressSmokeTestWarnings = 1 << 4 }; Q_DECLARE_FLAGS(Flags, Flag) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index 4dcda25d185..d357a6b2db0 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -291,21 +291,24 @@ bool QRhiD3D11::create(QRhi::Flags flags) return false; } + const bool supports11_1 = SUCCEEDED(ctx->QueryInterface(__uuidof(ID3D11DeviceContext1), reinterpret_cast(&context))); + ctx->Release(); + if (!supports11_1) { + qWarning("ID3D11DeviceContext1 not supported"); + return false; + } + // Test if creating a Shader Model 5.0 vertex shader works; we want to // fail already in create() if that's not the case. ID3D11VertexShader *testShader = nullptr; if (SUCCEEDED(dev->CreateVertexShader(g_testVertexShader, sizeof(g_testVertexShader), nullptr, &testShader))) { testShader->Release(); } else { - qWarning("D3D11 smoke test failed (failed to create vertex shader)"); - ctx->Release(); - return false; - } - - const bool supports11_1 = SUCCEEDED(ctx->QueryInterface(__uuidof(ID3D11DeviceContext1), reinterpret_cast(&context))); - ctx->Release(); - if (!supports11_1) { - qWarning("ID3D11DeviceContext1 not supported"); + static const char *msg = "D3D11 smoke test: Failed to create vertex shader"; + if (flags.testFlag(QRhi::SuppressSmokeTestWarnings)) + qCDebug(QRHI_LOG_INFO, "%s", msg); + else + qWarning("%s", msg); return false; } @@ -315,11 +318,19 @@ bool QRhiD3D11::create(QRhi::Flags flags) // still not support this D3D_FEATURE_LEVEL_11_1 feature. (e.g. // because it only does 11_0) if (!features.ConstantBufferOffsetting) { - qWarning("Constant buffer offsetting is not supported by the driver"); + static const char *msg = "D3D11 smoke test: Constant buffer offsetting is not supported by the driver"; + if (flags.testFlag(QRhi::SuppressSmokeTestWarnings)) + qCDebug(QRHI_LOG_INFO, "%s", msg); + else + qWarning("%s", msg); return false; } } else { - qWarning("Failed to query D3D11_FEATURE_D3D11_OPTIONS"); + static const char *msg = "D3D11 smoke test: Failed to query D3D11_FEATURE_D3D11_OPTIONS"; + if (flags.testFlag(QRhi::SuppressSmokeTestWarnings)) + qCDebug(QRHI_LOG_INFO, "%s", msg); + else + qWarning("%s", msg); return false; } } else {