diff options
Diffstat (limited to 'src/gui/opengl/qopenglfunctions.cpp')
-rw-r--r-- | src/gui/opengl/qopenglfunctions.cpp | 87 |
1 files changed, 44 insertions, 43 deletions
diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index bc1bad2831..c9352fbc31 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -1,41 +1,5 @@ -/**************************************************************************** -** -** Copyright (C) 2021 The Qt Company Ltd. -** Contact: https://www.qt.io/licensing/ -** -** This file is part of the QtGui module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** 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 https://www.qt.io/terms-conditions. For further -** information use the contact form at https://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.LGPL3 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-3.0.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 (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ +// Copyright (C) 2021 The Qt Company Ltd. +// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only #include "qopenglfunctions.h" #include "qopenglextrafunctions.h" @@ -57,6 +21,8 @@ QT_BEGIN_NAMESPACE +using namespace Qt::StringLiterals; + #define QT_OPENGL_COUNT_FUNCTIONS(ret, name, args) +1 #define QT_OPENGL_FUNCTION_NAMES(ret, name, args) \ "gl"#name"\0" @@ -364,6 +330,8 @@ static int qt_gl_resolve_extensions() extensions |= QOpenGLExtensions::ETC1TextureCompression; if (extensionMatcher.match("GL_IMG_texture_compression_pvrtc")) extensions |= QOpenGLExtensions::PVRTCTextureCompression; + if (extensionMatcher.match("GL_KHR_texture_compression_astc_ldr")) + extensions |= QOpenGLExtensions::ASTCTextureCompression; if (extensionMatcher.match("GL_ARB_texture_mirrored_repeat")) extensions |= QOpenGLExtensions::MirroredRepeat; if (extensionMatcher.match("GL_EXT_stencil_two_side")) @@ -378,6 +346,12 @@ static int qt_gl_resolve_extensions() extensions |= QOpenGLExtensions::TextureSwizzle; if (extensionMatcher.match("GL_OES_standard_derivatives")) extensions |= QOpenGLExtensions::StandardDerivatives; + if (extensionMatcher.match("GL_ARB_half_float_vertex")) + extensions |= QOpenGLExtensions::HalfFloatVertex; + if (extensionMatcher.match("GL_OVR_multiview")) + extensions |= QOpenGLExtensions::MultiView; + if (extensionMatcher.match("GL_OVR_multiview2")) + extensions |= QOpenGLExtensions::MultiViewExtended; if (ctx->isOpenGLES()) { if (format.majorVersion() >= 2) @@ -391,7 +365,10 @@ static int qt_gl_resolve_extensions() | QOpenGLExtensions::FramebufferBlit | QOpenGLExtensions::FramebufferMultisample | QOpenGLExtensions::Sized8Formats - | QOpenGLExtensions::StandardDerivatives; + | QOpenGLExtensions::DiscardFramebuffer + | QOpenGLExtensions::StandardDerivatives + | QOpenGLExtensions::ETC2TextureCompression + | QOpenGLExtensions::HalfFloatVertex; #ifndef Q_OS_WASM // WebGL 2.0 specification explicitly does not support texture swizzles // https://www.khronos.org/registry/webgl/specs/latest/2.0/#5.19 @@ -413,6 +390,8 @@ static int qt_gl_resolve_extensions() extensions |= QOpenGLExtensions::FramebufferMultisample; if (extensionMatcher.match("GL_OES_rgb8_rgba8")) extensions |= QOpenGLExtensions::Sized8Formats; + if (extensionMatcher.match("GL_OES_compressed_ETC2_RGB8_texture")) + extensions |= QOpenGLExtensions::ETC2TextureCompression; } if (extensionMatcher.match("GL_OES_mapbuffer")) @@ -426,9 +405,9 @@ static int qt_gl_resolve_extensions() QString *deviceName = static_cast<QString *>(QGuiApplication::platformNativeInterface()->nativeResourceForIntegration("AndroidDeviceName")); static bool wrongfullyReportsBgra8888Support = deviceName != 0 - && (deviceName->compare(QLatin1String("samsung SM-T211"), Qt::CaseInsensitive) == 0 - || deviceName->compare(QLatin1String("samsung SM-T210"), Qt::CaseInsensitive) == 0 - || deviceName->compare(QLatin1String("samsung SM-T215"), Qt::CaseInsensitive) == 0); + && (deviceName->compare("samsung SM-T211"_L1, Qt::CaseInsensitive) == 0 + || deviceName->compare("samsung SM-T210"_L1, Qt::CaseInsensitive) == 0 + || deviceName->compare("samsung SM-T215"_L1, Qt::CaseInsensitive) == 0); if (wrongfullyReportsBgra8888Support) extensions &= ~QOpenGLExtensions::BGRATextureFormat; #endif @@ -472,6 +451,9 @@ static int qt_gl_resolve_extensions() if (format.version() >= qMakePair(3, 3)) extensions |= QOpenGLExtensions::TextureSwizzle; + if (format.version() >= qMakePair(4, 3) || extensionMatcher.match("GL_ARB_invalidate_subdata")) + extensions |= QOpenGLExtensions::DiscardFramebuffer; + if (extensionMatcher.match("GL_ARB_map_buffer_range")) extensions |= QOpenGLExtensions::MapBufferRange; @@ -481,6 +463,9 @@ static int qt_gl_resolve_extensions() if (srgbCapableFramebuffers) extensions |= QOpenGLExtensions::SRGBFrameBuffer; } + + if (extensionMatcher.match("GL_ARB_ES3_compatibility")) + extensions |= QOpenGLExtensions::ETC2TextureCompression; } return extensions; @@ -5070,7 +5055,23 @@ QOpenGLExtensionsPrivate::QOpenGLExtensionsPrivate(QOpenGLContext *ctx) MapBuffer = RESOLVE(MapBuffer); GetBufferSubData = RESOLVE(GetBufferSubData); DiscardFramebuffer = RESOLVE(DiscardFramebuffer); - } +} + +void QOpenGLExtensions::discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments) +{ + Q_D(QOpenGLExtensions); + Q_ASSERT(QOpenGLExtensions::isInitialized(d)); + Q_ASSERT(d->f.InvalidateFramebuffer || d->DiscardFramebuffer); + + // On GLES >= 3 we prefer glInvalidateFramebuffer, even if the + // discard extension is present + if (d->f.InvalidateFramebuffer) + d->f.InvalidateFramebuffer(target, numAttachments, attachments); + else + d->DiscardFramebuffer(target, numAttachments, attachments); + + Q_OPENGL_FUNCTIONS_DEBUG +} void QOpenGLExtensions::flushShared() { |