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(); }
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);
284 if (
matches(
it->toObject(), osName, kernelVersion, osRelease, gpu))
289 const QJsonValue vendorV =
object.value(
"vendor_id"_L1);
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()) {
361 if (eit->isObject()) {
363 if (
matches(
object, osName, kernelVersion, osRelease, gpu)) {
364 const QJsonValue featuresListV =
object.value(
"features"_L1);
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);
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);
qsizetype count(QByteArrayView a) const noexcept
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)
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.
const_iterator constBegin() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the first item in the array.
const_iterator constEnd() const
Returns a const \l{STL-style iterators}{STL-style iterator} pointing to the imaginary item after the ...
\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
bool isString() const
Returns true if the value contains a string.
QJsonArray toArray() const
This is an overloaded member function, provided for convenience. It differs from the above function o...
bool isArray() const
Returns true if the value contains an array.
Type type() const
Returns the type of the value.
QString toString() const
Converts the value to a QString and returns it.
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 QOperatingSystemVersion current()
[0]
static constexpr QOperatingSystemVersionBase Windows11
\variable QOperatingSystemVersion::Windows11
T * data() const noexcept
Returns the value of the pointer referenced by this object.
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
Deletes the existing object it is pointing to (if any), and sets its pointer to other.
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
iterator insert(const T &value)
\macro QT_RESTRICTED_CAST_FROM_ASCII
void clear()
Clears the contents of the string and makes it null.
uint toUInt(bool *ok=nullptr, int base=10) const
Returns the string converted to an {unsigned int} using base base, which is 10 by default and must be...
bool isEmpty() const
Returns true if the string has no characters; otherwise returns false.
QByteArray toUtf8() const &
QString & prepend(QChar c)
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
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