From 95198e7ad53e88c34d4f391c80d434031f21f768 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Mon, 3 Apr 2023 11:57:36 +0200 Subject: [PATCH] rhi: d3d11: Check ConstantBufferOffsetting in feature data This is an additional attempt to have more "smoke testing" in place for systems where there is no real 11_1 level driver present. (we already test for Shader Model 5.0 above, now also check this 11.1 feature indicating that VSSetConstantBuffers1 is actually implemented) This probing is important in particular for Qt Quick, where there is an automatic retry with the software (WARP) adapter when the initial QRhi::create() returns false. This may or may not help the virtual machine case in the associated issue, but is a valid check regardless since we absolutely require constant buffer offsetting. Task-number: QTBUG-78648 Pick-to: 6.5 6.4 6.2 Change-Id: I4d3c7b5c6c1f2b04b16c84b42c92651a3e671617 Reviewed-by: Qt CI Bot Reviewed-by: Andy Nichols --- src/gui/rhi/qrhid3d11.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/gui/rhi/qrhid3d11.cpp b/src/gui/rhi/qrhid3d11.cpp index d9f323eb1a5..15b713192e9 100644 --- a/src/gui/rhi/qrhid3d11.cpp +++ b/src/gui/rhi/qrhid3d11.cpp @@ -278,6 +278,20 @@ bool QRhiD3D11::create(QRhi::Flags flags) qWarning("ID3D11DeviceContext1 not supported"); return false; } + + D3D11_FEATURE_DATA_D3D11_OPTIONS features = {}; + if (SUCCEEDED(dev->CheckFeatureSupport(D3D11_FEATURE_D3D11_OPTIONS, &features, sizeof(features)))) { + // The D3D _runtime_ may be 11.1, but the underlying _driver_ may + // 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"); + return false; + } + } else { + qWarning("Failed to query D3D11_FEATURE_D3D11_OPTIONS"); + return false; + } } else { Q_ASSERT(dev && context); featureLevel = dev->GetFeatureLevel();