summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/core/web_engine_context.cpp34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/core/web_engine_context.cpp b/src/core/web_engine_context.cpp
index be462a22d..973da88a7 100644
--- a/src/core/web_engine_context.cpp
+++ b/src/core/web_engine_context.cpp
@@ -4,6 +4,7 @@
#include "web_engine_context.h"
#include <math.h>
+#include <QtGui/private/qrhi_p.h>
#include "base/base_switches.h"
#include "base/bind.h"
@@ -177,6 +178,31 @@ bool usingSoftwareDynamicGL()
#endif
}
+#if defined(Q_OS_WIN)
+static QString getAdapterLuid() {
+ static const bool preferSoftwareDevice = qEnvironmentVariableIntValue("QSG_RHI_PREFER_SOFTWARE_RENDERER");
+ QRhiD3D11InitParams rhiParams;
+ QRhi::Flags flags;
+ if (preferSoftwareDevice) {
+ flags |= QRhi::PreferSoftwareRenderer;
+ }
+ QScopedPointer<QRhi> rhi(QRhi::create(QRhi::D3D11,&rhiParams,flags,nullptr));
+ // mimic what QSGRhiSupport and QBackingStoreRhi does
+ if (!rhi && !preferSoftwareDevice) {
+ flags |= QRhi::PreferSoftwareRenderer;
+ rhi.reset(QRhi::create(QRhi::D3D11, &rhiParams, flags));
+ }
+ if (rhi) {
+ const QRhiD3D11NativeHandles *handles =
+ static_cast<const QRhiD3D11NativeHandles *>(rhi->nativeHandles());
+ Q_ASSERT(handles);
+ return QString("%1,%2").arg(handles->adapterLuidHigh).arg(handles->adapterLuidLow);
+ } else {
+ return QString();
+ }
+}
+#endif
+
static bool openGLPlatformSupport()
{
return QGuiApplicationPrivate::platformIntegration()->hasCapability(
@@ -727,6 +753,14 @@ WebEngineContext::WebEngineContext()
}
#endif
+#if defined(Q_OS_WIN)
+ if (QQuickWindow::graphicsApi() == QSGRendererInterface::Direct3D11) {
+ const QString luid = getAdapterLuid();
+ if (!luid.isEmpty())
+ parsedCommandLine->AppendSwitchASCII(switches::kUseAdapterLuid, luid.toStdString());
+ }
+#endif
+
initializeFeatureList(parsedCommandLine, enableFeatures, disableFeatures);
GLContextHelper::initialize();