12#include <QtCore/QDebug>
13#include <QtCore/QJsonDocument>
14#include <QtCore/QJsonValue>
15#include <QtCore/QJsonObject>
16#include <QtCore/QJsonArray>
17#include <QtCore/QTextStream>
18#include <QtCore/QFile>
25#if defined(QT_OPENGL_3)
29#ifndef GL_CONTEXT_LOST
30#define GL_CONTEXT_LOST 0x0507
37 qWarning(
"QOpenGLExtensionMatcher::QOpenGLExtensionMatcher: No context");
41 const char *extensionStr =
nullptr;
43 if (
ctx->isOpenGLES() ||
ctx->format().majorVersion() < 3)
44 extensionStr =
reinterpret_cast<const char *
>(
funcs->glGetString(GL_EXTENSIONS));
55 if (
error == GL_NO_ERROR)
65 GLint numExtensions = 0;
68 for (
int i = 0;
i < numExtensions; ++
i) {
69 const char *
str =
reinterpret_cast<const char *
>(glGetStringi(GL_EXTENSIONS,
i));
106 <<
"version=" <<
g.driverVersion;
119 if (needle ==
it->toString().toUInt(
nullptr, 0))
128 if (needle ==
it->toString())
136static const char operators[][3] = {
"!=",
"<",
"<=",
"=",
">",
">="};
153 qWarning(
"called with invalid parameters");
167 case GreaterEqualThan:
173VersionTerm VersionTerm::fromJson(
const QJsonValue &
v)
180 const QString opS =
o.value(
"op"_L1).toString();
181 for (
size_t i = 0;
i <
sizeof(operators) /
sizeof(operators[0]); ++
i) {
197 static QString hostOsRelease() {
207 bool isNull()
const {
return type.isEmpty(); }
210 if (
isNull() || osName.isEmpty() || kernelVersion.
isNull()) {
211 qWarning(
"called with invalid parameters");
216 if (!versionTerm.isNull() && !versionTerm.matches(kernelVersion))
225 VersionTerm versionTerm;
229OsTypeTerm OsTypeTerm::fromJson(
const QJsonValue &
v)
235 result.type =
o.value(
"type"_L1).toString();
236 result.versionTerm = VersionTerm::fromJson(
o.value(
"version"_L1));
237 result.release =
o.value(
"release"_L1).toArray();
246#elif defined(Q_OS_LINUX)
248#elif defined(Q_OS_MACOS)
250#elif defined(Q_OS_ANDROID)
262 <<
" (\"" <<
object.value(
"description"_L1).toString()
276 const OsTypeTerm os = OsTypeTerm::fromJson(
object.
value(
"os"_L1));
277 if (!os.isNull() && !os.matches(osName, kernelVersion, osRelease))
280 const QJsonValue exceptionsV =
object.value(
"exceptions"_L1);
281 if (exceptionsV.isArray()) {
282 const QJsonArray exceptionsA = exceptionsV.toArray();
284 if (
matches(
it->toObject(), osName, kernelVersion, osRelease, gpu))
289 const QJsonValue vendorV =
object.value(
"vendor_id"_L1);
290 if (vendorV.isString()) {
291 if (gpu.
vendorId != vendorV.toString().toUInt(
nullptr, 0))
294 if (
object.
contains(
"gl_vendor"_L1)) {
295 const QByteArray glVendorV =
object.value(
"gl_vendor"_L1).toString().toUtf8();
302 const QJsonValue deviceIdV =
object.value(
"device_id"_L1);
303 switch (deviceIdV.type()) {
317 const QJsonValue driverVersionV =
object.value(
"driver_version"_L1);
318 switch (driverVersionV.type()) {
333 const QJsonValue driverDescriptionV =
object.value(
"driver_description"_L1);
334 if (driverDescriptionV.isString()) {
354 if (!entriesV.isArray()) {
359 const QJsonArray entriesA = entriesV.toArray();
360 for (
JsonArrayConstIt eit = entriesA.constBegin(), ecend = entriesA.constEnd(); eit != ecend; ++eit) {
361 if (eit->isObject()) {
363 if (
matches(
object, osName, kernelVersion, osRelease, gpu)) {
364 const QJsonValue featuresListV =
object.value(
"features"_L1);
365 if (featuresListV.isArray()) {
366 const QJsonArray featuresListA = featuresListV.toArray();
367 for (
JsonArrayConstIt fit = featuresListA.constBegin(), fcend = featuresListA.constEnd(); fit != fcend; ++fit)
387 if (document.isNull()) {
391 str <<
"Failed to parse data: \"" <<
error.errorString()
392 <<
"\" at line " << lineNumber <<
" (offset: "
393 <<
error.offset <<
").";
452 return gpuFeatures(gpu, OsTypeTerm::hostOs(), OsTypeTerm::hostKernelVersion(), OsTypeTerm::hostOsRelease(), doc);
457 return gpuFeatures(gpu, OsTypeTerm::hostOs(), OsTypeTerm::hostKernelVersion(), OsTypeTerm::hostOsRelease(),
fileName);
463 QScopedPointer<QOpenGLContext> tmpContext;
464 QScopedPointer<QOffscreenSurface> tmpSurface;
467 if (!tmpContext->create()) {
468 qWarning(
"QOpenGLConfig::Gpu::fromContext: Failed to create temporary context");
472 tmpSurface->setFormat(tmpContext->format());
473 tmpSurface->create();
474 tmpContext->makeCurrent(tmpSurface.data());
479 const GLubyte *
p =
ctx->functions()->glGetString(GL_VENDOR);
constexpr QByteArrayView left(qsizetype n) const
QList< QByteArray > split(char sep) const
Splits the byte array into subarrays wherever sep occurs, and returns the list of those arrays.
bool contains(char c) const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isEmpty() const noexcept
Returns true if the byte array has size 0; otherwise returns false.
static QString toNativeSeparators(const QString &pathName)
QFILE_MAYBE_NODISCARD bool open(OpenMode flags) override
Opens the file using OpenMode mode, returning true if successful; otherwise false.
QByteArray readAll()
Reads all remaining data from the device, and returns it as a byte array.
QString errorString() const
Returns a human-readable description of the last device error that occurred.
\inmodule QtCore\reentrant
void insert(qsizetype i, const QJsonValue &value)
Inserts value at index position i in the array.
\inmodule QtCore\reentrant
QJsonObject object() const
Returns the QJsonObject contained in the document.
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
Parses json as a UTF-8 encoded JSON document, and creates a QJsonDocument from it.
\inmodule QtCore\reentrant
QJsonValue value(const QString &key) const
Returns a QJsonValue representing the value for the key key.
\inmodule QtCore\reentrant
static QSet< QString > gpuFeatures(const Gpu &gpu, const QString &osName, const QVersionNumber &kernelVersion, const QString &osVersion, const QJsonDocument &doc)
static QOpenGLContext * currentContext()
Returns the last context which called makeCurrent in the current thread, or \nullptr,...
QOpenGLExtensionMatcher()
QSet< QByteArray > extensions() const
The QOpenGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
static Q_CORE_EXPORT QOperatingSystemVersionBase current()
static constexpr QOperatingSystemVersionBase Windows11
\variable QOperatingSystemVersion::Windows11
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
iterator insert(const T &value)
\macro QT_RESTRICTED_CAST_FROM_ASCII
static QString kernelVersion()
bool isNull() const noexcept
Returns true if there are zero numerical segments, otherwise returns false.
static Q_CORE_EXPORT QVersionNumber fromString(QAnyStringView string, qsizetype *suffixIndex=nullptr)
static VulkanServerBufferGlFunctions * funcs
QSet< QString >::iterator it
Combined button and popup list for selecting options.
QTextStream & hex(QTextStream &stream)
Calls QTextStream::setIntegerBase(16) on stream and returns stream.
QTextStream & showbase(QTextStream &stream)
Calls QTextStream::setNumberFlags(QTextStream::numberFlags() | QTextStream::ShowBase) on stream and r...
DBusConnection const char DBusError * error
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
EGLOutputLayerEXT EGLint EGLAttrib value
[5]
static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu, const QString &osName, const QVersionNumber &kernelVersion, const QString &osRelease, const QJsonDocument &doc, QSet< QString > *result, QString *errorMessage)
const GLubyte *QOPENGLF_APIENTRYP qt_glGetStringi(GLenum, GLuint)
static QString msgSyntaxWarning(const QJsonObject &object, const QString &what)
static bool contains(const QJsonArray &haystack, unsigned needle)
QDebug operator<<(QDebug d, const QOpenGLConfig::Gpu &g)
static bool matches(const QJsonObject &object, const QString &osName, const QVersionNumber &kernelVersion, const QString &osRelease, const QOpenGLConfig::Gpu &gpu)
QJsonArray::ConstIterator JsonArrayConstIt
#define QOPENGLF_APIENTRYP
typedef GLint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)(GLuint program
GLsizei const GLfloat * v
[13]
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
#define GL_NUM_EXTENSIONS
#define QStringLiteral(str)
static QString errorMessage(QUrlPrivate::ErrorCode errorCode, const QString &errorSource, qsizetype errorPosition)
\inmodule QtCore\reentrant
QVersionNumber driverVersion
QByteArray driverDescription