48 #include <QtCore/QDebug>
49 #include <QtCore/QJsonDocument>
50 #include <QtCore/QJsonValue>
51 #include <QtCore/QJsonObject>
52 #include <QtCore/QJsonArray>
53 #include <QtCore/QTextStream>
54 #include <QtCore/QFile>
55 #include <QtCore/QDir>
59 #if defined(QT_OPENGL_3)
63 #ifndef GL_CONTEXT_LOST
64 #define GL_CONTEXT_LOST 0x0507
71 qWarning(
"QOpenGLExtensionMatcher::QOpenGLExtensionMatcher: No context");
75 const char *extensionStr =
nullptr;
78 extensionStr =
reinterpret_cast<const char *
>(funcs->
glGetString(GL_EXTENSIONS));
89 if (
error == GL_NO_ERROR)
99 GLint numExtensions = 0;
102 for (
int i = 0;
i < numExtensions; ++
i) {
103 const char *
str =
reinterpret_cast<const char *
>(glGetStringi(GL_EXTENSIONS,
i));
140 <<
"version=" <<
g.driverVersion;
153 if (needle ==
it->toString().toUInt(
nullptr, 0))
162 if (needle ==
it->toString())
169 enum Operator { NotEqual, LessThan, LessEqualThan,
Equals, GreaterThan, GreaterEqualThan };
170 static const char operators[][3] = {
"!=",
"<",
"<=",
"=",
">",
">="};
175 VersionTerm() :
op(NotEqual) {}
177 bool isNull()
const {
return number.isNull(); }
186 if (isNull() ||
other.isNull()) {
187 qWarning(
"called with invalid parameters");
201 case GreaterEqualThan:
207 VersionTerm VersionTerm::fromJson(
const QJsonValue &
v)
215 for (
size_t i = 0;
i <
sizeof(operators) /
sizeof(operators[0]); ++
i) {
231 static QString hostOsRelease() {
235 #define Q_WINVER(major, minor) (major << 8 | minor)
236 switch (Q_WINVER(osver.majorVersion(), osver.minorVersion())) {
246 case Q_WINVER(10, 0):
260 if (isNull() || osName.
isEmpty() || kernelVersion.
isNull()) {
261 qWarning(
"called with invalid parameters");
266 if (!versionTerm.isNull() && !versionTerm.matches(kernelVersion))
275 VersionTerm versionTerm;
279 OsTypeTerm OsTypeTerm::fromJson(
const QJsonValue &
v)
294 #if defined(Q_OS_WIN)
296 #elif defined(Q_OS_LINUX)
298 #elif defined(Q_OS_MACOS)
300 #elif defined(Q_OS_ANDROID)
312 <<
" (\"" <<
object.value(
QLatin1String(
"description")).toString()
327 if (!os.isNull() && !os.matches(osName, kernelVersion, osRelease))
334 if (matches(
it->toObject(), osName, kernelVersion, osRelease, gpu))
353 switch (deviceIdV.
type()) {
363 << msgSyntaxWarning(
object,
369 switch (driverVersionV.
type()) {
371 if (!VersionTerm::fromJson(driverVersionV).matches(gpu.
driverVersion))
379 << msgSyntaxWarning(
object,
386 if (driverDescriptionV.
isString()) {
404 errorMessage->
clear();
413 if (eit->isObject()) {
415 if (matches(
object, osName, kernelVersion, osRelease, gpu)) {
436 errorMessage->
clear();
440 const int lineNumber = 1 + jsonAsciiData.
left(
error.offset).
count(
'\n');
442 str <<
"Failed to parse data: \"" <<
error.errorString()
443 <<
"\" at line " << lineNumber <<
" (offset: "
444 <<
error.offset <<
").";
447 return readGpuFeatures(gpu, osName, kernelVersion, osRelease,
document,
result, errorMessage);
458 errorMessage->
clear();
466 const bool success = readGpuFeatures(gpu, osName, kernelVersion, osRelease,
file.
readAll(),
result, errorMessage);
483 if (!readGpuFeatures(gpu, osName, kernelVersion, osRelease, doc, &
result, &errorMessage))
484 qWarning().noquote() << errorMessage;
496 if (!readGpuFeatures(gpu, osName, kernelVersion, osRelease,
fileName, &
result, &errorMessage))
497 qWarning().noquote() << errorMessage;
503 return gpuFeatures(gpu, OsTypeTerm::hostOs(), OsTypeTerm::hostKernelVersion(), OsTypeTerm::hostOsRelease(), doc);
508 return gpuFeatures(gpu, OsTypeTerm::hostOs(), OsTypeTerm::hostKernelVersion(), OsTypeTerm::hostOsRelease(),
fileName);
518 if (!tmpContext->
create()) {
519 qWarning(
"QOpenGLConfig::Gpu::fromContext: Failed to create temporary context");
small capitals from c petite p scientific i
[1]
The QByteArray class provides an array of bytes.
QList< QByteArray > split(char sep) const
bool contains(char c) const
bool isEmpty() const noexcept
QByteArray left(qsizetype len) const
qsizetype count(char c) const
operator<<(QDataStream &ds, qfloat16 f)
The QDebug class provides an output stream for debugging information.
Convenience class for custom QDebug operators.
static QString toNativeSeparators(const QString &pathName)
The QFile class provides an interface for reading from and writing to files.
bool open(OpenMode flags) override
QString errorString() const
The QJsonArray::const_iterator class provides an STL-style const iterator for QJsonArray.
The QJsonArray class encapsulates a JSON array.
void insert(qsizetype i, const QJsonValue &value)
const_iterator constBegin() const
const_iterator constEnd() const
The QJsonDocument class provides a way to read and write JSON documents.
QJsonObject object() const
static QJsonDocument fromJson(const QByteArray &json, QJsonParseError *error=nullptr)
The QJsonObject class encapsulates a JSON object.
QJsonValue value(const QString &key) const
The QJsonValue class encapsulates a value in JSON.
QJsonArray toArray() const
The QLatin1String class provides a thin wrapper around an US-ASCII/Latin-1 encoded string literal.
The QOffscreenSurface class represents an offscreen surface in the underlying platform.
void setFormat(const QSurfaceFormat &format)
static QSet< QString > gpuFeatures(const Gpu &gpu, const QString &osName, const QVersionNumber &kernelVersion, const QString &osVersion, const QJsonDocument &doc)
The QOpenGLContext class represents a native OpenGL context, enabling OpenGL rendering on a QSurface.
QFunctionPointer getProcAddress(const QByteArray &procName) const
bool makeCurrent(QSurface *surface)
QSurfaceFormat format() const
static QOpenGLContext * currentContext()
QOpenGLFunctions * functions() const
QOpenGLExtensionMatcher()
QSet< QByteArray > extensions() const
The QOpenGLFunctions class provides cross-platform access to the OpenGL ES 2.0 API.
const GLubyte * glGetString(GLenum name)
void glGetIntegerv(GLenum pname, GLint *params)
static QOperatingSystemVersion current()
[0]
T * data() const noexcept
void reset(T *other=nullptr) noexcept(noexcept(Cleanup::cleanup(std::declval< T * >())))
const_iterator constBegin() const noexcept
const_iterator constEnd() const noexcept
iterator insert(const T &value)
The QString class provides a Unicode character string.
QString & prepend(QChar c)
uint toUInt(bool *ok=nullptr, int base=10) const
QByteArray toUtf8() const &
static QString kernelVersion()
The QTextStream class provides a convenient interface for reading and writing text.
The QVersionNumber class contains a version number with an arbitrary number of segments.
bool isNull() const noexcept
static Q_CORE_EXPORT QVersionNumber fromString(const QString &string, int *suffixIndex=nullptr)
StdString::EqualsMatcher Equals(std::string const &str, CaseSensitive::Choice caseSensitivity=CaseSensitive::Yes)
void toString(QString &appendTo, IPv4Address address)
const PluginKeyMapConstIterator cend
QTextStream & hex(QTextStream &stream)
QTextStream & showbase(QTextStream &stream)
set set set set set set set macro pixldst1 op
typedef QByteArray(EGLAPIENTRYP PFNQGSGETDISPLAYSPROC)()
QT_BEGIN_NAMESPACE typedef const GLubyte *QOPENGLF_APIENTRYP qt_glGetStringi(GLenum, GLuint)
QJsonArray::ConstIterator JsonArrayConstIt
#define QOPENGLF_APIENTRYP
typedef GLint(GL_APIENTRYP PFNGLGETPROGRAMRESOURCELOCATIONINDEXEXTPROC)(GLuint program
GLsizei const GLfloat * v
[13]
typedef GLenum(GL_APIENTRYP PFNGLGETGRAPHICSRESETSTATUSKHRPROC)(void)
typedef GLuint(GL_APIENTRYP PFNGLGETDEBUGMESSAGELOGKHRPROC)(GLuint count
#define GL_NUM_EXTENSIONS
#define QStringLiteral(str)
The QJsonParseError class is used to report errors during JSON parsing.
QVersionNumber driverVersion
QByteArray driverDescription