72QSGAdaptationBackendData *contextFactory()
74 QSGAdaptationBackendData *backendData = qsg_adaptation_data();
76 if (!backendData->tried) {
77 backendData->tried =
true;
79 const QStringList args = QGuiApplication::arguments();
80 QString requestedBackend = backendData->quickWindowBackendRequest;
82 for (
int index = 0; index < args.size(); ++index) {
83 if (args.at(index).startsWith(QLatin1String(
"--device="))) {
84 requestedBackend = args.at(index).mid(9);
89 if (requestedBackend.isEmpty())
90 requestedBackend = qEnvironmentVariable(
"QMLSCENE_DEVICE");
95 if (requestedBackend.isEmpty())
96 requestedBackend = qEnvironmentVariable(
"QT_QUICK_BACKEND");
104#if !QT_CONFIG(opengl) && !QT_CONFIG(vulkan) && !QT_CONFIG(metal) && !defined(Q_OS_WIN)
105 if (requestedBackend.isEmpty())
106 requestedBackend = QLatin1String(
"software");
116 if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::RhiBasedRendering)) {
117 if (requestedBackend.isEmpty())
118 requestedBackend = QLatin1String(
"software");
123 if (requestedBackend == QLatin1String(
"rhi"))
124 requestedBackend.clear();
126 if (!requestedBackend.isEmpty()) {
127 qCDebug(QSG_LOG_INFO,
"Loading backend %s", qUtf8Printable(requestedBackend));
130 for (QSGContextFactoryInterface *builtInBackend : std::as_const(backendData->builtIns)) {
131 if (builtInBackend->keys().contains(requestedBackend)) {
132 backendData->factory = builtInBackend;
133 backendData->name = requestedBackend;
134 backendData->flags = backendData->factory->flags(requestedBackend);
139#if QT_CONFIG(library)
141 if (!backendData->factory) {
142 const int index = loader()->indexOf(requestedBackend);
144 backendData->factory = qobject_cast<QSGContextFactoryInterface*>(loader()->instance(index));
145 if (backendData->factory) {
146 backendData->name = requestedBackend;
147 backendData->flags = backendData->factory->flags(requestedBackend);
149 if (!backendData->factory) {
150 qWarning(
"Could not create scene graph context for backend '%s'"
151 " - check that plugins are installed correctly in %s",
152 qPrintable(requestedBackend),
153 qPrintable(QLibraryInfo::path(QLibraryInfo::PluginsPath)));