From e68f76e6ab9457652d6de0712120695d2fbb81b8 Mon Sep 17 00:00:00 2001 From: John Preston Date: Wed, 21 Jul 2021 21:18:04 +0300 Subject: [PATCH] List and allow to query EGL extensions on Windows. --- ui/gl/gl_detection.cpp | 28 ++++++++++++++++++++++++++++ ui/gl/gl_detection.h | 3 +++ 2 files changed, 31 insertions(+) diff --git a/ui/gl/gl_detection.cpp b/ui/gl/gl_detection.cpp index 5973083..7b3f851 100644 --- a/ui/gl/gl_detection.cpp +++ b/ui/gl/gl_detection.cpp @@ -17,6 +17,12 @@ #include #include +#ifdef Q_OS_WIN +#include +#include +#include +#endif // Q_OS_WIN + #define LOG_ONCE(x) [[maybe_unused]] static auto logged = [&] { LOG(x); return true; }(); namespace Ui::GL { @@ -142,6 +148,15 @@ Capabilities CheckCapabilities(QWidget *widget) { list.append(QString::fromLatin1(extension)); } LOG(("OpenGL Extensions: %1").arg(list.join(", "))); + +#ifdef Q_OS_WIN + auto egllist = QStringList(); + for (const auto &extension : EGLExtensions(context)) { + egllist.append(QString::fromLatin1(extension)); + } + LOG(("EGL Extensions: %1").arg(egllist.join(", "))); +#endif // Q_OS_WIN + return true; }(); @@ -225,6 +240,19 @@ ANGLE CurrentANGLE() { return ResolvedANGLE; } +QList EGLExtensions(not_null context) { + const auto native = QGuiApplication::platformNativeInterface(); + Assert(native != nullptr); + + const auto display = static_cast( + native->nativeResourceForContext( + QByteArrayLiteral("egldisplay"), + context)); + return display + ? QByteArray(eglQueryString(display, EGL_EXTENSIONS)).split(' ') + : QList(); +} + #endif // Q_OS_WIN } // namespace Ui::GL diff --git a/ui/gl/gl_detection.h b/ui/gl/gl_detection.h index c50cab7..6c1ef91 100644 --- a/ui/gl/gl_detection.h +++ b/ui/gl/gl_detection.h @@ -40,4 +40,7 @@ void ConfigureANGLE(); // Requires Ui::Integration being set. void ChangeANGLE(ANGLE backend); [[nodiscard]] ANGLE CurrentANGLE(); +[[nodiscard]] QList EGLExtensions( + not_null context); + } // namespace Ui::GL