diff --git a/abstract_opengl_context_attribute_builder.h b/abstract_opengl_context_attribute_builder.h --- a/abstract_opengl_context_attribute_builder.h +++ b/abstract_opengl_context_attribute_builder.h @@ -94,6 +94,14 @@ return m_resetOnVideoMemoryPurge; } + void setHighPriority(bool highPriority) { + m_highPriority = highPriority; + } + + bool isHighPriority() const { + return m_highPriority; + } + virtual std::vector build() const = 0; QDebug operator<<(QDebug dbg) const; @@ -107,6 +115,7 @@ bool m_coreProfile = false; bool m_compatibilityProfile = false; bool m_resetOnVideoMemoryPurge = false; + bool m_highPriority = false; }; inline QDebug operator<<(QDebug dbg, const AbstractOpenGLContextAttributeBuilder *attribs) diff --git a/abstract_opengl_context_attribute_builder.cpp b/abstract_opengl_context_attribute_builder.cpp --- a/abstract_opengl_context_attribute_builder.cpp +++ b/abstract_opengl_context_attribute_builder.cpp @@ -32,7 +32,8 @@ dbg.nospace() << "Robust:\t" << isRobust() << "\n"; dbg.nospace() << "Forward compatible:\t" << isForwardCompatible() << "\n"; dbg.nospace() << "Core profile:\t" << isCoreProfile() << "\n"; - dbg.nospace() << "Compatibility profile:\t" << isCompatibilityProfile(); + dbg.nospace() << "Compatibility profile:\t" << isCompatibilityProfile() << "\n"; + dbg.nospace() << "High priority:\t" << isHighPriority(); return dbg; } diff --git a/egl_context_attribute_builder.cpp b/egl_context_attribute_builder.cpp --- a/egl_context_attribute_builder.cpp +++ b/egl_context_attribute_builder.cpp @@ -52,6 +52,10 @@ attribs.emplace_back(EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR); } } + if (isHighPriority()) { + attribs.emplace_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG); + attribs.emplace_back(EGL_CONTEXT_PRIORITY_HIGH_IMG); + } attribs.emplace_back(EGL_NONE); return attribs; } @@ -67,6 +71,10 @@ attribs.emplace_back(EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_EXT); attribs.emplace_back(EGL_LOSE_CONTEXT_ON_RESET_EXT); } + if (isHighPriority()) { + attribs.emplace_back(EGL_CONTEXT_PRIORITY_LEVEL_IMG); + attribs.emplace_back(EGL_CONTEXT_PRIORITY_HIGH_IMG); + } attribs.emplace_back(EGL_NONE); return attribs; } diff --git a/platformsupport/scenes/opengl/abstract_egl_backend.cpp b/platformsupport/scenes/opengl/abstract_egl_backend.cpp --- a/platformsupport/scenes/opengl/abstract_egl_backend.cpp +++ b/platformsupport/scenes/opengl/abstract_egl_backend.cpp @@ -217,33 +217,39 @@ { const bool haveRobustness = hasExtension(QByteArrayLiteral("EGL_EXT_create_context_robustness")); const bool haveCreateContext = hasExtension(QByteArrayLiteral("EGL_KHR_create_context")); + const bool haveContextPriority = hasExtension(QByteArrayLiteral("EGL_IMG_context_priority")); std::vector> candidates; if (isOpenGLES()) { if (haveCreateContext && haveRobustness) { auto glesRobust = std::unique_ptr(new EglOpenGLESContextAttributeBuilder); glesRobust->setVersion(2); glesRobust->setRobust(true); + glesRobust->setHighPriority(haveContextPriority); candidates.push_back(std::move(glesRobust)); } auto gles = std::unique_ptr(new EglOpenGLESContextAttributeBuilder); gles->setVersion(2); + gles->setHighPriority(haveContextPriority); candidates.push_back(std::move(gles)); } else { if (options->glCoreProfile() && haveCreateContext) { if (haveRobustness) { auto robustCore = std::unique_ptr(new EglContextAttributeBuilder); robustCore->setVersion(3, 1); robustCore->setRobust(true); + robustCore->setHighPriority(haveContextPriority); candidates.push_back(std::move(robustCore)); } auto core = std::unique_ptr(new EglContextAttributeBuilder); core->setVersion(3, 1); + core->setHighPriority(haveContextPriority); candidates.push_back(std::move(core)); } if (haveRobustness && haveCreateContext) { auto robust = std::unique_ptr(new EglContextAttributeBuilder); robust->setRobust(true); + robust->setHighPriority(haveContextPriority); candidates.push_back(std::move(robust)); } candidates.emplace_back(new EglContextAttributeBuilder); diff --git a/plugins/qpa/abstractplatformcontext.cpp b/plugins/qpa/abstractplatformcontext.cpp --- a/plugins/qpa/abstractplatformcontext.cpp +++ b/plugins/qpa/abstractplatformcontext.cpp @@ -146,17 +146,20 @@ const QList extensions = eglExtensions.split(' '); const bool haveRobustness = extensions.contains(QByteArrayLiteral("EGL_EXT_create_context_robustness")); const bool haveCreateContext = extensions.contains(QByteArrayLiteral("EGL_KHR_create_context")); + const bool haveContextPriority = extensions.contains(QByteArrayLiteral("EGL_IMG_context_priority")); std::vector> candidates; if (isOpenGLES()) { if (haveCreateContext && haveRobustness) { auto glesRobust = std::unique_ptr(new EglOpenGLESContextAttributeBuilder); glesRobust->setVersion(2); glesRobust->setRobust(true); + glesRobust->setHighPriority(haveContextPriority); candidates.push_back(std::move(glesRobust)); } auto gles = std::unique_ptr(new EglOpenGLESContextAttributeBuilder); gles->setVersion(2); + gles->setHighPriority(haveContextPriority); candidates.push_back(std::move(gles)); } else { // Try to create a 3.1 core context @@ -171,6 +174,7 @@ } else if (m_format.profile() == QSurfaceFormat::CompatibilityProfile) { robustCore->setCompatibilityProfile(true); } + robustCore->setHighPriority(haveContextPriority); candidates.push_back(std::move(robustCore)); } auto core = std::unique_ptr(new EglContextAttributeBuilder); @@ -181,12 +185,14 @@ } else if (m_format.profile() == QSurfaceFormat::CompatibilityProfile) { core->setCompatibilityProfile(true); } + core->setHighPriority(haveContextPriority); candidates.push_back(std::move(core)); } if (haveRobustness && haveCreateContext) { auto robust = std::unique_ptr(new EglContextAttributeBuilder); robust->setRobust(true); + robust->setHighPriority(haveContextPriority); candidates.push_back(std::move(robust)); } candidates.emplace_back(new EglContextAttributeBuilder);