From cd61b6c969dee74776ad7e9f3dcf1e1623b1059b Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Wed, 8 Apr 2015 10:33:36 +0200 Subject: Add a cast to glTexImage2D to keep QNX happy MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The internalformat parameter seems to be GLenum (unsigned int) on QNX based on the error message in the linked bug report. The standard is GLint, though. To keep everyone happy, add a cast. Task-number: QTBUG-45346 Change-Id: I57fece7b381e0d02acc842a21b1edc5451ea0224 Reviewed-by: Sérgio Martins Reviewed-by: Rafael Roquetto --- src/gui/opengl/qopengltexturehelper.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/gui/opengl') diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp index e1e3593f4f..442fa4c22c 100644 --- a/src/gui/opengl/qopengltexturehelper.cpp +++ b/src/gui/opengl/qopengltexturehelper.cpp @@ -171,7 +171,7 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context) GetTexParameteriv = ::glGetTexParameteriv; GetTexParameterfv = ::glGetTexParameterfv; GetTexImage = 0; - TexImage2D = ::glTexImage2D; + TexImage2D = reinterpret_cast(::glTexImage2D); TexImage1D = 0; TexParameteriv = ::glTexParameteriv; TexParameteri = ::glTexParameteri; -- cgit v1.2.3 From 71e3ce7f0b671ac8bb6607d18d4fa16c6c81f737 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 26 Mar 2015 16:39:13 +0100 Subject: The default wrap mode is REPEAT As per spec, both for OpenGL and OpenGL ES. No wrap mode is applied unless setWrapMode() is called so the default values should be initialized to match OpenGL's default. Correct the copy-paste mistake in the warning messages. Change-Id: I094cc511dc7de4a214da61faadb1fc362270b2d4 Reviewed-by: Giuseppe D'Angelo --- src/gui/opengl/qopengltexture.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/gui/opengl') diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index 9bc9926b70..baa702a982 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -120,7 +120,8 @@ QOpenGLTexturePrivate::QOpenGLTexturePrivate(QOpenGLTexture::Target textureTarge swizzleMask[2] = QOpenGLTexture::BlueValue; swizzleMask[3] = QOpenGLTexture::AlphaValue; - wrapModes[0] = wrapModes[1] = wrapModes[2] = QOpenGLTexture::ClampToEdge; + wrapModes[0] = wrapModes[1] = wrapModes[2] = target == QOpenGLTexture::TargetRectangle + ? QOpenGLTexture::ClampToEdge : QOpenGLTexture::Repeat; } QOpenGLTexturePrivate::~QOpenGLTexturePrivate() @@ -215,7 +216,8 @@ void QOpenGLTexturePrivate::destroy() swizzleMask[2] = QOpenGLTexture::BlueValue; swizzleMask[3] = QOpenGLTexture::AlphaValue; - wrapModes[0] = wrapModes[1] = wrapModes[2] = QOpenGLTexture::ClampToEdge; + wrapModes[0] = wrapModes[1] = wrapModes[2] = target == QOpenGLTexture::TargetRectangle + ? QOpenGLTexture::ClampToEdge : QOpenGLTexture::Repeat; } void QOpenGLTexturePrivate::bind() @@ -1393,7 +1395,7 @@ QOpenGLTexture::WrapMode QOpenGLTexturePrivate::wrapMode(QOpenGLTexture::Coordin case QOpenGLTexture::DirectionT: case QOpenGLTexture::DirectionR: - qWarning("QOpenGLTexture::setWrapMode() direction not valid for this texture target"); + qWarning("QOpenGLTexture::wrapMode() direction not valid for this texture target"); return QOpenGLTexture::Repeat; } break; @@ -1413,7 +1415,7 @@ QOpenGLTexture::WrapMode QOpenGLTexturePrivate::wrapMode(QOpenGLTexture::Coordin return wrapModes[1]; case QOpenGLTexture::DirectionR: - qWarning("QOpenGLTexture::setWrapMode() direction not valid for this texture target"); + qWarning("QOpenGLTexture::wrapMode() direction not valid for this texture target"); return QOpenGLTexture::Repeat; } break; -- cgit v1.2.3 From f3fad26bc9e0fde3bcf1625da731aeb02b04a7a5 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 9 Apr 2015 16:49:34 +0200 Subject: Add matching by GL_VENDOR to QOpenGLConfig This will be essential on Linux, especially Embedded where PCI IDs are not that useful. Change-Id: I2fa8ca07236e8aae203e21fe629d12aab092c7fd Reviewed-by: Friedemann Kleint --- src/gui/opengl/qopengl.cpp | 42 ++++++++++++++++++++++++++++++++++-------- src/gui/opengl/qopengl_p.h | 24 +++++++++++++++++++++--- 2 files changed, 55 insertions(+), 11 deletions(-) (limited to 'src/gui/opengl') diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index 61d0614724..c8d33df4ba 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -36,6 +36,7 @@ #include "qopenglcontext.h" #include "qopenglfunctions.h" +#include "qoffscreensurface.h" #include #include @@ -89,8 +90,8 @@ QOpenGLExtensionMatcher::QOpenGLExtensionMatcher() } /* Helpers to read out the list of features matching a device from - * a Chromium driver bug list of the format using a subset of keys - * (namely, matching by gl_vendor RegExp is not implemented): + * a Chromium driver bug list. Note that not all keys are supported and + * some may behave differently: gl_vendor is a substring match instead of regex. { "entries": [ { @@ -291,14 +292,14 @@ static bool matches(const QJsonObject &object, const QJsonValue vendorV = object.value(vendorIdKey()); if (vendorV.isString()) { - if (gpu.vendorId != vendorV.toString().toUInt(Q_NULLPTR, /* base */ 0)) - return false; + if (gpu.vendorId != vendorV.toString().toUInt(Q_NULLPTR, /* base */ 0)) + return false; } else { if (object.contains(glVendorKey())) { - qWarning().nospace() << "Id " << object.value(idKey()).toInt() - << ": Matching by " << glVendorKey() << " is not implemented."; - return false; - } + const QByteArray glVendorV = object.value(glVendorKey()).toString().toUtf8(); + if (!gpu.glVendor.contains(glVendorV)) + return false; + } } if (gpu.deviceId) { @@ -447,5 +448,30 @@ QSet QOpenGLConfig::gpuFeatures(const Gpu &gpu, const QString &fileName return gpuFeatures(gpu, OsTypeTerm::hostOs(), OsTypeTerm::hostKernelVersion(), fileName); } +QOpenGLConfig::Gpu QOpenGLConfig::Gpu::fromContext() +{ + QOpenGLContext *ctx = QOpenGLContext::currentContext(); + QScopedPointer tmpContext; + QScopedPointer tmpSurface; + if (!ctx) { + tmpContext.reset(new QOpenGLContext); + if (!tmpContext->create()) { + qWarning("QOpenGLConfig::Gpu::fromContext: Failed to create temporary context"); + return QOpenGLConfig::Gpu(); + } + tmpSurface.reset(new QOffscreenSurface); + tmpSurface->setFormat(tmpContext->format()); + tmpSurface->create(); + tmpContext->makeCurrent(tmpSurface.data()); + } + + QOpenGLConfig::Gpu gpu; + ctx = QOpenGLContext::currentContext(); + const GLubyte *p = ctx->functions()->glGetString(GL_VENDOR); + if (p) + gpu.glVendor = QByteArray(reinterpret_cast(p)); + + return gpu; +} QT_END_NAMESPACE diff --git a/src/gui/opengl/qopengl_p.h b/src/gui/opengl/qopengl_p.h index e04ae05120..980e02aea6 100644 --- a/src/gui/opengl/qopengl_p.h +++ b/src/gui/opengl/qopengl_p.h @@ -74,16 +74,34 @@ private: class Q_GUI_EXPORT QOpenGLConfig { public: - struct Gpu { + struct Q_GUI_EXPORT Gpu { Gpu() : vendorId(0), deviceId(0) {} - bool isValid() const { return deviceId; } + bool isValid() const { return deviceId || !glVendor.isEmpty(); } bool equals(const Gpu &other) const { - return vendorId == other.vendorId && deviceId == other.deviceId && driverVersion == other.driverVersion; + return vendorId == other.vendorId && deviceId == other.deviceId && driverVersion == other.driverVersion + && glVendor == other.glVendor; } uint vendorId; uint deviceId; QVersionNumber driverVersion; + QByteArray glVendor; + + static Gpu fromDevice(uint vendorId, uint deviceId, QVersionNumber driverVersion) { + Gpu gpu; + gpu.vendorId = vendorId; + gpu.deviceId = deviceId; + gpu.driverVersion = driverVersion; + return gpu; + } + + static Gpu fromGLVendor(const QByteArray &glVendor) { + Gpu gpu; + gpu.glVendor = glVendor; + return gpu; + } + + static Gpu fromContext(); }; static QSet gpuFeatures(const Gpu &gpu, -- cgit v1.2.3