diff options
-rw-r--r-- | src/imports/qtcanvas3d/canvas3d.cpp | 7 | ||||
-rw-r--r-- | src/imports/qtcanvas3d/canvasrenderer.cpp | 17 | ||||
-rw-r--r-- | src/imports/qtcanvas3d/glstatestore.cpp | 2 | ||||
-rw-r--r-- | src/imports/qtcanvas3d/openglversionchecker.cpp | 89 | ||||
-rw-r--r-- | src/imports/qtcanvas3d/openglversionchecker_p.h | 74 | ||||
-rw-r--r-- | src/imports/qtcanvas3d/qtcanvas3d.pro | 6 | ||||
-rw-r--r-- | sync.profile | 10 |
7 files changed, 173 insertions, 32 deletions
diff --git a/src/imports/qtcanvas3d/canvas3d.cpp b/src/imports/qtcanvas3d/canvas3d.cpp index 072c4b3..598fb17 100644 --- a/src/imports/qtcanvas3d/canvas3d.cpp +++ b/src/imports/qtcanvas3d/canvas3d.cpp @@ -46,6 +46,7 @@ #include "canvasglstatedump_p.h" #include "renderjob_p.h" #include "canvasrenderer_p.h" +#include "openglversionchecker_p.h" #include <QtGui/QGuiApplication> #include <QtGui/QOffscreenSurface> @@ -118,10 +119,8 @@ Canvas::Canvas(QQuickItem *parent): m_runningInDesigner = QGuiApplication::applicationDisplayName() == "Qml2Puppet"; setFlag(ItemHasContents, !(m_runningInDesigner || m_renderTarget != RenderTargetOffscreenBuffer)); -#if (QT_VERSION >= QT_VERSION_CHECK(5, 4, 0)) - if (QCoreApplication::testAttribute(Qt::AA_UseSoftwareOpenGL)) - m_isSoftwareRendered = true; -#endif + OpenGLVersionChecker checker; + m_isSoftwareRendered = checker.isSoftwareRenderer(); } /*! diff --git a/src/imports/qtcanvas3d/canvasrenderer.cpp b/src/imports/qtcanvas3d/canvasrenderer.cpp index 192e8a7..db16051 100644 --- a/src/imports/qtcanvas3d/canvasrenderer.cpp +++ b/src/imports/qtcanvas3d/canvasrenderer.cpp @@ -204,19 +204,6 @@ void CanvasRenderer::init(QQuickWindow *window, const CanvasContextAttributes &c m_executeStartIndex = 0; m_executeEndIndex = 0; -#ifndef QT_NO_DEBUG - const GLubyte *version = m_glContext->functions()->glGetString(GL_VERSION); - qCDebug(canvas3dinfo).nospace() << "CanvasRenderer::" << __FUNCTION__ - << "OpenGL version:" << (const char *)version; - - version = m_glContext->functions()->glGetString(GL_SHADING_LANGUAGE_VERSION); - qCDebug(canvas3dinfo).nospace() << "CanvasRenderer::" << __FUNCTION__ - << "GLSL version:" << (const char *)version; - - qCDebug(canvas3dinfo).nospace() << "CanvasRenderer::" << __FUNCTION__ - << "EXTENSIONS: " << extensions; -#endif - #if defined(Q_OS_WIN) // Check driver vendor. We need to do some additional checking with Intel GPUs in Windows, // as our FBOs can get corrupted when some unrelated Qt Quick items are @@ -1176,7 +1163,7 @@ void CanvasRenderer::executeCommandQueue() } case CanvasGlCommandQueue::glDrawElements: { glDrawElements(GLenum(command.i1), GLsizei(command.i2), GLenum(command.i3), - reinterpret_cast<GLvoid *>(command.i4)); + reinterpret_cast<GLvoid *>(qintptr(command.i4))); break; } case CanvasGlCommandQueue::glEnable: { @@ -1483,7 +1470,7 @@ void CanvasRenderer::executeCommandQueue() case CanvasGlCommandQueue::glVertexAttribPointer: { glVertexAttribPointer(GLuint(command.i1), command.i2, GLenum(command.i3), GLboolean(command.i4), GLsizei(command.i5), - reinterpret_cast<const GLvoid *>(command.i6)); + reinterpret_cast<const GLvoid *>(qintptr(command.i6))); break; } case CanvasGlCommandQueue::glViewport: { diff --git a/src/imports/qtcanvas3d/glstatestore.cpp b/src/imports/qtcanvas3d/glstatestore.cpp index 2f68f76..3bfecdf 100644 --- a/src/imports/qtcanvas3d/glstatestore.cpp +++ b/src/imports/qtcanvas3d/glstatestore.cpp @@ -484,7 +484,7 @@ void GLStateStore::restoreStoredState() m_vertexAttribArrayTypes[i], m_vertexAttribArrayNormalized[i], m_vertexAttribArrayStrides[i], - reinterpret_cast<const GLvoid *>(m_vertexAttribArrayOffsets[i])); + reinterpret_cast<const GLvoid *>(qintptr(m_vertexAttribArrayOffsets[i]))); } glBindBuffer(GL_ARRAY_BUFFER, m_boundArrayBuffer); diff --git a/src/imports/qtcanvas3d/openglversionchecker.cpp b/src/imports/qtcanvas3d/openglversionchecker.cpp new file mode 100644 index 0000000..f7f3d69 --- /dev/null +++ b/src/imports/qtcanvas3d/openglversionchecker.cpp @@ -0,0 +1,89 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtCanvas3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "openglversionchecker_p.h" +#include "canvas3d_p.h" +#include <QtGui/QOpenGLContext> +#include <QtGui/QOpenGLFunctions> +#include <QtGui/QOffscreenSurface> + +QT_BEGIN_NAMESPACE +QT_CANVAS3D_BEGIN_NAMESPACE + +OpenGLVersionChecker::OpenGLVersionChecker() : + m_softwareRenderer(false) +{ + QOpenGLContext *context = QOpenGLContext::currentContext(); + QOffscreenSurface *surface = 0; + bool createdContext = false; + if (!context) { + context = new QOpenGLContext; + createdContext = context->create(); + if (!createdContext) { + qCWarning(canvas3drendering, + "%s Warning: Couldn't resolve context for version checking.", __FUNCTION__); + delete context; + return; + } else { + surface = new QOffscreenSurface(); + surface->setFormat(context->format()); + surface->create(); + context->makeCurrent(surface); + } + } + + const GLubyte *glVersion = context->functions()->glGetString(GL_VERSION); + qCDebug(canvas3drendering, "%s OpenGL version: %s", __FUNCTION__, (const char*)glVersion); + + const GLubyte *glslVersion = context->functions()->glGetString(GL_SHADING_LANGUAGE_VERSION); + qCDebug(canvas3drendering, "%s GLSL version: %s", __FUNCTION__, (const char*)glslVersion); + + qCDebug(canvas3drendering) << __FUNCTION__ << "EXTENSIONS: " << context->extensions(); + + QString versionStr = QString::fromLatin1((const char *)glVersion).toLower(); + if (versionStr.contains(QStringLiteral("mesa")) + || versionStr.contains(QStringLiteral("llvmpipe"))) { + m_softwareRenderer = true; + } + if (createdContext) { + context->doneCurrent(); + delete context; + delete surface; + } +} + +QT_CANVAS3D_END_NAMESPACE +QT_END_NAMESPACE diff --git a/src/imports/qtcanvas3d/openglversionchecker_p.h b/src/imports/qtcanvas3d/openglversionchecker_p.h new file mode 100644 index 0000000..d2505e0 --- /dev/null +++ b/src/imports/qtcanvas3d/openglversionchecker_p.h @@ -0,0 +1,74 @@ +/**************************************************************************** +** +** Copyright (C) 2016 The Qt Company Ltd. +** Contact: http://www.qt.io/licensing/ +** +** This file is part of the QtCanvas3D module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL3$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see http://www.qt.io/terms-conditions. For further +** information use the contact form at http://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPLv3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or later as published by the Free +** Software Foundation and appearing in the file LICENSE.GPL included in +** the packaging of this file. Please review the following information to +** ensure the GNU General Public License version 2.0 requirements will be +** met: http://www.gnu.org/licenses/gpl-2.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +// +// W A R N I N G +// ------------- +// +// This file is not part of the QtCanvas3D API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. + +#ifndef OPENGLVERSIONCHECKER_P_H +#define OPENGLVERSIONCHECKER_P_H + +#include "canvas3dcommon_p.h" +#include <QtCore/qglobal.h> + +QT_BEGIN_NAMESPACE +QT_CANVAS3D_BEGIN_NAMESPACE + +class OpenGLVersionChecker +{ + Q_DISABLE_COPY(OpenGLVersionChecker) + +public: + OpenGLVersionChecker(); + ~OpenGLVersionChecker() {}; + + bool isSoftwareRenderer() const { return m_softwareRenderer; } + +private: + bool m_softwareRenderer; +}; + +QT_CANVAS3D_END_NAMESPACE +QT_END_NAMESPACE + +#endif // OPENGLVERSIONCHECKER_P_H + diff --git a/src/imports/qtcanvas3d/qtcanvas3d.pro b/src/imports/qtcanvas3d/qtcanvas3d.pro index 4d4d7c2..9780c2e 100644 --- a/src/imports/qtcanvas3d/qtcanvas3d.pro +++ b/src/imports/qtcanvas3d/qtcanvas3d.pro @@ -30,7 +30,8 @@ SOURCES += arrayutils.cpp \ renderjob.cpp \ canvasrenderer.cpp \ canvastextureprovider.cpp \ - glstatestore.cpp + glstatestore.cpp \ + openglversionchecker.cpp HEADERS += arrayutils_p.h \ qcanvas3d_plugin.h \ @@ -58,7 +59,8 @@ HEADERS += arrayutils_p.h \ renderjob_p.h \ canvasrenderer_p.h \ canvastextureprovider_p.h \ - glstatestore_p.h + glstatestore_p.h \ + openglversionchecker_p.h OTHER_FILES = qmldir \ doc/* \ diff --git a/sync.profile b/sync.profile index 133eb08..fbd493a 100644 --- a/sync.profile +++ b/sync.profile @@ -3,13 +3,3 @@ ); %moduleheaders = ( # restrict the module headers to those found in relative path ); -# Module dependencies. -# Every module that is required to build this module should have one entry. -# Each of the module version specifiers can take one of the following values: -# - A specific Git revision. -# - any git symbolic ref resolvable from the module's repository (e.g. "refs/heads/master" to track master branch) -# -%dependencies = ( - "qtbase" => "", - "qtdeclarative" => "", -); |