73QSGAdaptationBackendData *contextFactory()
75 QSGAdaptationBackendData *backendData = qsg_adaptation_data();
77 if (!backendData->tried) {
78 backendData->tried =
true;
80 const QStringList args = QGuiApplication::arguments();
81 QString requestedBackend = backendData->quickWindowBackendRequest;
83 for (
int index = 0; index < args.size(); ++index) {
84 if (args.at(index).startsWith(QLatin1String(
"--device="))) {
85 requestedBackend = args.at(index).mid(9);
90 if (requestedBackend.isEmpty())
91 requestedBackend = qEnvironmentVariable(
"QMLSCENE_DEVICE");
96 if (requestedBackend.isEmpty())
97 requestedBackend = qEnvironmentVariable(
"QT_QUICK_BACKEND");
105#if !QT_CONFIG(opengl) && !QT_CONFIG(vulkan) && !QT_CONFIG(metal) && !defined(Q_OS_WIN)
106 if (requestedBackend.isEmpty())
107 requestedBackend = QLatin1String(
"software");
117 if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RhiBasedRendering)) {
118 if (requestedBackend.isEmpty())
119 requestedBackend = QLatin1String(
"software");
124 if (requestedBackend == QLatin1String(
"rhi"))
125 requestedBackend.clear();
127 if (!requestedBackend.isEmpty()) {
128 qCDebug(QSG_LOG_INFO,
"Loading backend %s", qUtf8Printable(requestedBackend));
131 for (QSGContextFactoryInterface *builtInBackend : std::as_const(backendData->builtIns)) {
132 if (builtInBackend->keys().contains(requestedBackend)) {
133 backendData->factory = builtInBackend;
134 backendData->name = requestedBackend;
135 backendData->flags = backendData->factory->flags(requestedBackend);
140#if QT_CONFIG(library)
142 if (!backendData->factory) {
143 const int index = loader()->indexOf(requestedBackend);
145 backendData->factory = qobject_cast<QSGContextFactoryInterface*>(loader()->instance(index));
146 if (backendData->factory) {
147 backendData->name = requestedBackend;
148 backendData->flags = backendData->factory->flags(requestedBackend);
150 if (!backendData->factory) {
151 qWarning(
"Could not create scene graph context for backend '%s'"
152 " - check that plugins are installed correctly in %s",
153 qPrintable(requestedBackend),
154 qPrintable(QLibraryInfo::path(QLibraryInfo::PluginsPath)));