48 if (m_rhi || m_cpuOnly)
51 const QPlatformIntegration *qpa = QGuiApplicationPrivate::platformIntegration();
53 if (qpa && qpa->hasCapability(QPlatformIntegration::RhiBasedRendering)) {
56 if (canUseRhiImpl(QRhi::Metal, backend)) {
57 QRhiMetalInitParams params;
58 m_rhi.reset(QRhi::create(QRhi::Metal, ¶ms));
63 if (!m_rhi && canUseRhiImpl(QRhi::D3D11, backend)) {
64 QRhiD3D11InitParams params;
65 m_rhi.reset(QRhi::create(QRhi::D3D11, ¶ms));
70 if (!m_rhi && canUseRhiImpl(QRhi::OpenGLES2, backend)) {
71 if (openGLCapsSupported(*qpa)) {
73 m_fallbackSurface.reset(QRhiGles2InitParams::newFallbackSurface());
74 QRhiGles2InitParams params;
75 params.fallbackSurface = m_fallbackSurface.get();
76 m_rhi.reset(QRhi::create(QRhi::OpenGLES2, ¶ms));
78# if defined(Q_OS_ANDROID)
81 if (!m_appStateChangedConnection) {
82 if (!m_eventsReceiver)
83 m_eventsReceiver = std::make_unique<QObject>();
85 auto onStateChanged = [
this](
auto state) {
86 if (state == Qt::ApplicationSuspended)
90 m_appStateChangedConnection =
91 QObject::connect(qApp, &QGuiApplication::applicationStateChanged,
92 m_eventsReceiver.get(), onStateChanged);
100 if (!m_rhi && canUseRhiImpl(QRhi::Vulkan, backend)) {
101 auto instance = std::make_unique<QVulkanInstance>();
102 instance->setExtensions(QRhiVulkanInitParams::preferredInstanceExtensions());
103 if (instance->create()) {
104 QRhiVulkanInitParams params;
105 params.inst = instance.get();
106 m_rhi.reset(QRhi::create(QRhi::Vulkan, ¶ms));
108 qCDebug(qLcThreadLocalRhi) <<
"Failed to create QVulkanInstance";
112 m_vulkanInstance = std::move(instance);
119 qCWarning(qLcThreadLocalRhi)
120 << Q_FUNC_INFO <<
": No RHI backend. Using CPU conversion.";
139 const QRhi::Implementation reference)
142 if (reference != QRhi::Null)
143 return implementation == reference;
146 if (s_preferredBackend != QRhi::Null)
147 return implementation == s_preferredBackend;