diff options
Diffstat (limited to 'src/gui/opengl')
-rw-r--r-- | src/gui/opengl/platform/egl/qeglconvenience.cpp | 16 | ||||
-rw-r--r-- | src/gui/opengl/platform/egl/qeglplatformcontext_p.h | 6 | ||||
-rw-r--r-- | src/gui/opengl/platform/egl/qeglstreamconvenience_p.h | 4 | ||||
-rw-r--r-- | src/gui/opengl/platform/egl/qxlibeglintegration.cpp | 130 | ||||
-rw-r--r-- | src/gui/opengl/platform/egl/qxlibeglintegration_p.h | 33 | ||||
-rw-r--r-- | src/gui/opengl/platform/unix/qglxconvenience.cpp | 2 | ||||
-rw-r--r-- | src/gui/opengl/qopengl.cpp | 29 | ||||
-rw-r--r-- | src/gui/opengl/qopengl.h | 41 | ||||
-rw-r--r-- | src/gui/opengl/qopenglextensions_p.h | 15 | ||||
-rw-r--r-- | src/gui/opengl/qopenglfunctions.cpp | 31 | ||||
-rw-r--r-- | src/gui/opengl/qopenglfunctions.h | 2 | ||||
-rw-r--r-- | src/gui/opengl/qopenglprogrambinarycache_p.h | 4 | ||||
-rw-r--r-- | src/gui/opengl/qt_attribution.json | 4 |
13 files changed, 96 insertions, 221 deletions
diff --git a/src/gui/opengl/platform/egl/qeglconvenience.cpp b/src/gui/opengl/platform/egl/qeglconvenience.cpp index 3d5b99c38c..4af50d72f2 100644 --- a/src/gui/opengl/platform/egl/qeglconvenience.cpp +++ b/src/gui/opengl/platform/egl/qeglconvenience.cpp @@ -88,13 +88,12 @@ QList<EGLint> q_createConfigAttributesFromFormat(const QSurfaceFormat &format) bool q_reduceConfigAttributes(QList<EGLint> *configAttributes) { - int i = -1; // Reduce the complexity of a configuration request to ask for less // because the previous request did not result in success. Returns // true if the complexity was reduced, or false if no further // reductions in complexity are possible. - i = configAttributes->indexOf(EGL_SWAP_BEHAVIOR); + qsizetype i = configAttributes->indexOf(EGL_SWAP_BEHAVIOR); if (i >= 0) { configAttributes->remove(i,2); } @@ -216,14 +215,17 @@ EGLConfig QEglConfigChooser::chooseConfig() configureAttributes.append(EGL_OPENVG_BIT); break; #ifdef EGL_VERSION_1_4 - case QSurfaceFormat::DefaultRenderableType: + case QSurfaceFormat::DefaultRenderableType: { #ifndef QT_NO_OPENGL - if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL) + // NVIDIA EGL only provides desktop GL for development purposes, and recommends against using it. + const char *vendor = eglQueryString(display(), EGL_VENDOR); + if (QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL && (!vendor || !strstr(vendor, "NVIDIA"))) configureAttributes.append(EGL_OPENGL_BIT); else #endif // QT_NO_OPENGL needsES2Plus = true; break; + } case QSurfaceFormat::OpenGL: configureAttributes.append(EGL_OPENGL_BIT); break; @@ -255,7 +257,7 @@ EGLConfig QEglConfigChooser::chooseConfig() // Fetch all of the matching configurations and find the // first that matches the pixel format we wanted. - int i = configureAttributes.indexOf(EGL_RED_SIZE); + qsizetype i = configureAttributes.indexOf(EGL_RED_SIZE); m_confAttrRed = configureAttributes.at(i+1); i = configureAttributes.indexOf(EGL_GREEN_SIZE); m_confAttrGreen = configureAttributes.at(i+1); @@ -265,7 +267,8 @@ EGLConfig QEglConfigChooser::chooseConfig() m_confAttrAlpha = i == -1 ? 0 : configureAttributes.at(i+1); QList<EGLConfig> configs(matching); - eglChooseConfig(display(), configureAttributes.constData(), configs.data(), configs.size(), &matching); + eglChooseConfig(display(), configureAttributes.constData(), configs.data(), + EGLint(configs.size()), &matching); if (!cfg && matching > 0) cfg = configs.first(); @@ -353,6 +356,7 @@ QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, else if (referenceFormat.renderableType() == QSurfaceFormat::DefaultRenderableType #ifndef QT_NO_OPENGL && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL + && !strstr(eglQueryString(display, EGL_VENDOR), "NVIDIA") #endif && (renderableType & EGL_OPENGL_BIT)) format.setRenderableType(QSurfaceFormat::OpenGL); diff --git a/src/gui/opengl/platform/egl/qeglplatformcontext_p.h b/src/gui/opengl/platform/egl/qeglplatformcontext_p.h index 556fbabee4..b1e9c4b4c2 100644 --- a/src/gui/opengl/platform/egl/qeglplatformcontext_p.h +++ b/src/gui/opengl/platform/egl/qeglplatformcontext_p.h @@ -69,12 +69,14 @@ public: QSurfaceFormat format() const override; bool isSharing() const override { return m_shareContext != EGL_NO_CONTEXT; } - bool isValid() const override { return m_eglContext != EGL_NO_CONTEXT; } + bool isValid() const override { return m_eglContext != EGL_NO_CONTEXT && !m_markedInvalid; } EGLContext nativeContext() const override { return eglContext(); } EGLConfig config() const override { return eglConfig(); } EGLDisplay display() const override { return eglDisplay(); } + virtual void invalidateContext() override { m_markedInvalid = true; } + EGLContext eglContext() const; EGLDisplay eglDisplay() const; EGLConfig eglConfig() const; @@ -102,6 +104,8 @@ private: Flags m_flags; bool m_ownsContext = false; QList<EGLint> m_contextAttrs; + + bool m_markedInvalid = false; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QEGLPlatformContext::Flags) diff --git a/src/gui/opengl/platform/egl/qeglstreamconvenience_p.h b/src/gui/opengl/platform/egl/qeglstreamconvenience_p.h index d7c9012feb..edf73fe981 100644 --- a/src/gui/opengl/platform/egl/qeglstreamconvenience_p.h +++ b/src/gui/opengl/platform/egl/qeglstreamconvenience_p.h @@ -113,6 +113,10 @@ typedef EGLBoolean (EGLAPIENTRYP PFNEGLSTREAMCONSUMEROUTPUTEXTPROC) (EGLDisplay #define EGL_PLATFORM_X11_KHR 0x31D5 #endif +#ifndef EGL_PLATFORM_XCB_KHR +#define EGL_PLATFORM_XCB_KHR 0x31DC +#endif + #ifndef EGL_NV_stream_attrib typedef EGLStreamKHR (EGLAPIENTRYP PFNEGLCREATESTREAMATTRIBNVPROC) (EGLDisplay dpy, const EGLAttrib *attrib_list); typedef EGLBoolean (EGLAPIENTRYP PFNEGLSETSTREAMATTRIBNVPROC) (EGLDisplay dpy, EGLStreamKHR stream, EGLenum attribute, EGLAttrib value); diff --git a/src/gui/opengl/platform/egl/qxlibeglintegration.cpp b/src/gui/opengl/platform/egl/qxlibeglintegration.cpp deleted file mode 100644 index cfabedc8c0..0000000000 --- a/src/gui/opengl/platform/egl/qxlibeglintegration.cpp +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright (C) 2020 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 <QtCore/qloggingcategory.h> -#include "qxlibeglintegration_p.h" - -QT_BEGIN_NAMESPACE - -Q_LOGGING_CATEGORY(lcXlibEglDebug, "qt.egl.xlib.debug") - -VisualID QXlibEglIntegration::getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config) -{ - VisualID visualId = 0; - EGLint eglValue = 0; - - EGLint configRedSize = 0; - eglGetConfigAttrib(eglDisplay, config, EGL_RED_SIZE, &configRedSize); - - EGLint configGreenSize = 0; - eglGetConfigAttrib(eglDisplay, config, EGL_GREEN_SIZE, &configGreenSize); - - EGLint configBlueSize = 0; - eglGetConfigAttrib(eglDisplay, config, EGL_BLUE_SIZE, &configBlueSize); - - EGLint configAlphaSize = 0; - eglGetConfigAttrib(eglDisplay, config, EGL_ALPHA_SIZE, &configAlphaSize); - - eglGetConfigAttrib(eglDisplay, config, EGL_CONFIG_ID, &eglValue); - int configId = eglValue; - - // See if EGL provided a valid VisualID: - eglGetConfigAttrib(eglDisplay, config, EGL_NATIVE_VISUAL_ID, &eglValue); - visualId = (VisualID)eglValue; - if (visualId) { - // EGL has suggested a visual id, so get the rest of the visual info for that id: - XVisualInfo visualInfoTemplate; - memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); - visualInfoTemplate.visualid = visualId; - - XVisualInfo *chosenVisualInfo; - int matchingCount = 0; - chosenVisualInfo = XGetVisualInfo(display, VisualIDMask, &visualInfoTemplate, &matchingCount); - if (chosenVisualInfo) { - // Skip size checks if implementation supports non-matching visual - // and config (QTBUG-9444). - if (q_hasEglExtension(eglDisplay,"EGL_NV_post_convert_rounding")) { - XFree(chosenVisualInfo); - return visualId; - } - // Skip also for i.MX6 where 565 visuals are suggested for the default 444 configs and it works just fine. - const char *vendor = eglQueryString(eglDisplay, EGL_VENDOR); - if (vendor && strstr(vendor, "Vivante")) { - XFree(chosenVisualInfo); - return visualId; - } - - int visualRedSize = qPopulationCount(chosenVisualInfo->red_mask); - int visualGreenSize = qPopulationCount(chosenVisualInfo->green_mask); - int visualBlueSize = qPopulationCount(chosenVisualInfo->blue_mask); - int visualAlphaSize = chosenVisualInfo->depth - visualRedSize - visualBlueSize - visualGreenSize; - - const bool visualMatchesConfig = visualRedSize >= configRedSize - && visualGreenSize >= configGreenSize - && visualBlueSize >= configBlueSize - && visualAlphaSize >= configAlphaSize; - - // In some cases EGL tends to suggest a 24-bit visual for 8888 - // configs. In such a case we have to fall back to XGetVisualInfo. - if (!visualMatchesConfig) { - visualId = 0; - qCDebug(lcXlibEglDebug, - "EGL suggested using X Visual ID %d (%d %d %d %d depth %d) for EGL config %d" - "(%d %d %d %d), but this is incompatible", - (int)visualId, visualRedSize, visualGreenSize, visualBlueSize, visualAlphaSize, chosenVisualInfo->depth, - configId, configRedSize, configGreenSize, configBlueSize, configAlphaSize); - } - } else { - qCDebug(lcXlibEglDebug, "EGL suggested using X Visual ID %d for EGL config %d, but that isn't a valid ID", - (int)visualId, configId); - visualId = 0; - } - XFree(chosenVisualInfo); - } - else - qCDebug(lcXlibEglDebug, "EGL did not suggest a VisualID (EGL_NATIVE_VISUAL_ID was zero) for EGLConfig %d", configId); - - if (visualId) { - qCDebug(lcXlibEglDebug, configAlphaSize > 0 - ? "Using ARGB Visual ID %d provided by EGL for config %d" - : "Using Opaque Visual ID %d provided by EGL for config %d", (int)visualId, configId); - return visualId; - } - - // Finally, try to use XGetVisualInfo and only use the bit depths to match on: - if (!visualId) { - XVisualInfo visualInfoTemplate; - memset(&visualInfoTemplate, 0, sizeof(XVisualInfo)); - XVisualInfo *matchingVisuals; - int matchingCount = 0; - - visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize + configAlphaSize; - matchingVisuals = XGetVisualInfo(display, - VisualDepthMask, - &visualInfoTemplate, - &matchingCount); - if (!matchingVisuals) { - // Try again without taking the alpha channel into account: - visualInfoTemplate.depth = configRedSize + configGreenSize + configBlueSize; - matchingVisuals = XGetVisualInfo(display, - VisualDepthMask, - &visualInfoTemplate, - &matchingCount); - } - - if (matchingVisuals) { - visualId = matchingVisuals[0].visualid; - XFree(matchingVisuals); - } - } - - if (visualId) { - qCDebug(lcXlibEglDebug, "Using Visual ID %d provided by XGetVisualInfo for EGL config %d", (int)visualId, configId); - return visualId; - } - - qWarning("Unable to find an X11 visual which matches EGL config %d", configId); - return (VisualID)0; -} - -QT_END_NAMESPACE diff --git a/src/gui/opengl/platform/egl/qxlibeglintegration_p.h b/src/gui/opengl/platform/egl/qxlibeglintegration_p.h deleted file mode 100644 index 3e0ecbc6ea..0000000000 --- a/src/gui/opengl/platform/egl/qxlibeglintegration_p.h +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright (C) 2020 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 - -#ifndef QXLIBEGLINTEGRATION_H -#define QXLIBEGLINTEGRATION_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt 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. -// - -#include <QtGui/private/qeglconvenience_p.h> -#include <X11/X.h> -#include <X11/Xlib.h> -#include <X11/Xutil.h> - -QT_BEGIN_NAMESPACE - -class Q_GUI_EXPORT QXlibEglIntegration -{ -public: - static VisualID getCompatibleVisualId(Display *display, EGLDisplay eglDisplay, EGLConfig config); -}; - -QT_END_NAMESPACE - -#endif // QXLIBEGLINTEGRATION_H diff --git a/src/gui/opengl/platform/unix/qglxconvenience.cpp b/src/gui/opengl/platform/unix/qglxconvenience.cpp index a756caf343..ce70818042 100644 --- a/src/gui/opengl/platform/unix/qglxconvenience.cpp +++ b/src/gui/opengl/platform/unix/qglxconvenience.cpp @@ -124,7 +124,7 @@ struct QXcbSoftwareOpenGLEnforcer { } if (forceSoftwareOpenGL) - qputenv("LIBGL_ALWAYS_SOFTWARE", QByteArrayLiteral("1")); + qputenv("LIBGL_ALWAYS_SOFTWARE", "1"); } ~QXcbSoftwareOpenGLEnforcer() { diff --git a/src/gui/opengl/qopengl.cpp b/src/gui/opengl/qopengl.cpp index d8b22050c1..587975085a 100644 --- a/src/gui/opengl/qopengl.cpp +++ b/src/gui/opengl/qopengl.cpp @@ -195,29 +195,13 @@ struct OsTypeTerm static QString hostOs(); static QVersionNumber hostKernelVersion() { return QVersionNumber::fromString(QSysInfo::kernelVersion()); } static QString hostOsRelease() { - QString ver; #ifdef Q_OS_WIN - const auto osver = QOperatingSystemVersion::current(); -#define Q_WINVER(major, minor) (major << 8 | minor) - switch (Q_WINVER(osver.majorVersion(), osver.minorVersion())) { - case Q_WINVER(6, 1): - ver = QStringLiteral("7"); - break; - case Q_WINVER(6, 2): - ver = QStringLiteral("8"); - break; - case Q_WINVER(6, 3): - ver = QStringLiteral("8.1"); - break; - case Q_WINVER(10, 0): - ver = QStringLiteral("10"); - break; - default: - break; - } -#undef Q_WINVER + if (QOperatingSystemVersion::current() >= QOperatingSystemVersion::Windows11) + return u"11"_s; + return u"10"_s; +#else + return {}; #endif - return ver; } bool isNull() const { return type.isEmpty(); } @@ -401,7 +385,8 @@ static bool readGpuFeatures(const QOpenGLConfig::Gpu &gpu, QJsonParseError error; const QJsonDocument document = QJsonDocument::fromJson(jsonAsciiData, &error); if (document.isNull()) { - const int lineNumber = 1 + jsonAsciiData.left(error.offset).count('\n'); + const qsizetype lineNumber = + QByteArrayView(jsonAsciiData).left(error.offset).count('\n') + 1; QTextStream str(errorMessage); str << "Failed to parse data: \"" << error.errorString() << "\" at line " << lineNumber << " (offset: " diff --git a/src/gui/opengl/qopengl.h b/src/gui/opengl/qopengl.h index 7e5b8e6961..e9a11080ce 100644 --- a/src/gui/opengl/qopengl.h +++ b/src/gui/opengl/qopengl.h @@ -8,9 +8,19 @@ #ifndef QT_NO_OPENGL -// Windows always needs this to ensure that APIENTRY gets defined +// On Windows we need to ensure that APIENTRY and WINGDIAPI are defined before +// we can include gl.h. But we do not want to include <windows.h> in this public +// Qt header, as it pollutes the global namespace with macros. #if defined(Q_OS_WIN) -# include <QtCore/qt_windows.h> +# ifndef APIENTRY +# define APIENTRY __stdcall +# define Q_UNDEF_APIENTRY +# endif // APIENTRY +# ifndef WINGDIAPI +# define WINGDIAPI __declspec(dllimport) +# define Q_UNDEF_WINGDIAPI +# endif // WINGDIAPI +# define QT_APIENTRY __stdcall #endif // Note: Apple is a "controlled platform" for OpenGL ABI so we @@ -128,11 +138,11 @@ typedef char GLchar; // OS X 10.6 doesn't define these which are needed below // OS X 10.7 and later define them in gl3.h -#ifndef APIENTRY -#define APIENTRY +#ifndef QT_APIENTRY +#define QT_APIENTRY #endif -#ifndef APIENTRYP -#define APIENTRYP APIENTRY * +#ifndef QT_APIENTRYP +#define QT_APIENTRYP QT_APIENTRY * #endif #ifndef GLAPI #define GLAPI extern @@ -231,15 +241,15 @@ struct _cl_event; #endif #ifndef GL_ARB_debug_output -typedef void (APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam); +typedef void (QT_APIENTRY *GLDEBUGPROCARB)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam); #endif #ifndef GL_AMD_debug_output -typedef void (APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); +typedef void (QT_APIENTRY *GLDEBUGPROCAMD)(GLuint id,GLenum category,GLenum severity,GLsizei length,const GLchar *message,GLvoid *userParam); #endif #ifndef GL_KHR_debug -typedef void (APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam); +typedef void (QT_APIENTRY *GLDEBUGPROC)(GLenum source,GLenum type,GLuint id,GLenum severity,GLsizei length,const GLchar *message,const GLvoid *userParam); #endif #ifndef GL_NV_vdpau_interop @@ -256,8 +266,8 @@ typedef ptrdiff_t qopengl_GLintptr; typedef ptrdiff_t qopengl_GLsizeiptr; -#if defined(APIENTRY) && !defined(QOPENGLF_APIENTRY) -# define QOPENGLF_APIENTRY APIENTRY +#if defined(QT_APIENTRY) && !defined(QOPENGLF_APIENTRY) +# define QOPENGLF_APIENTRY QT_APIENTRY #endif # ifndef QOPENGLF_APIENTRYP @@ -271,6 +281,15 @@ typedef ptrdiff_t qopengl_GLsizeiptr; QT_END_NAMESPACE +#ifdef Q_UNDEF_WINGDIAPI +# undef WINGDIAPI +# undef Q_UNDEF_WINGDIAPI +#endif +#ifdef Q_UNDEF_APIENTRY +# undef APIENTRY +# undef Q_UNDEF_APIENTRY +#endif + #endif // QT_NO_OPENGL #endif // QOPENGL_H diff --git a/src/gui/opengl/qopenglextensions_p.h b/src/gui/opengl/qopenglextensions_p.h index 2924754e3a..a6c4a68c6c 100644 --- a/src/gui/opengl/qopenglextensions_p.h +++ b/src/gui/opengl/qopenglextensions_p.h @@ -58,7 +58,10 @@ public: TextureSwizzle = 0x01000000, StandardDerivatives = 0x02000000, ASTCTextureCompression = 0x04000000, - ETC2TextureCompression = 0x08000000 + ETC2TextureCompression = 0x08000000, + HalfFloatVertex = 0x10000000, + MultiView = 0x20000000, + MultiViewExtended = 0x40000000 }; Q_DECLARE_FLAGS(OpenGLExtensions, OpenGLExtension) @@ -67,9 +70,9 @@ public: GLvoid *glMapBuffer(GLenum target, GLenum access); void glGetBufferSubData(GLenum target, qopengl_GLintptr offset, qopengl_GLsizeiptr size, GLvoid *data); - void glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments); void flushShared(); + void discardFramebuffer(GLenum target, GLsizei numAttachments, const GLenum *attachments); QOpenGLExtensionsPrivate *d() const; @@ -114,14 +117,6 @@ inline void QOpenGLExtensions::glGetBufferSubData(GLenum target, qopengl_GLintpt Q_OPENGL_FUNCTIONS_DEBUG } - -inline void QOpenGLExtensions::glDiscardFramebufferEXT (GLenum target, GLsizei numAttachments, const GLenum *attachments) -{ - Q_D(QOpenGLExtensions); - Q_ASSERT(QOpenGLExtensions::isInitialized(d)); - d->DiscardFramebuffer(target,numAttachments, attachments); - Q_OPENGL_FUNCTIONS_DEBUG -} QT_END_NAMESPACE #endif // QOPENGL_EXTENSIONS_P_H diff --git a/src/gui/opengl/qopenglfunctions.cpp b/src/gui/opengl/qopenglfunctions.cpp index d8c8e4704d..c9352fbc31 100644 --- a/src/gui/opengl/qopenglfunctions.cpp +++ b/src/gui/opengl/qopenglfunctions.cpp @@ -346,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) @@ -359,8 +365,10 @@ static int qt_gl_resolve_extensions() | QOpenGLExtensions::FramebufferBlit | QOpenGLExtensions::FramebufferMultisample | QOpenGLExtensions::Sized8Formats + | QOpenGLExtensions::DiscardFramebuffer | QOpenGLExtensions::StandardDerivatives - | QOpenGLExtensions::ETC2TextureCompression; + | 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 @@ -443,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; @@ -5044,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() { diff --git a/src/gui/opengl/qopenglfunctions.h b/src/gui/opengl/qopenglfunctions.h index a3d100b847..05435903fb 100644 --- a/src/gui/opengl/qopenglfunctions.h +++ b/src/gui/opengl/qopenglfunctions.h @@ -191,7 +191,7 @@ struct QOpenGLFunctionsPrivate; #undef glTexLevelParameteriv -#if defined(Q_CLANG_QDOC) +#if defined(Q_QDOC) #undef GLbitfield typedef unsigned int GLbitfield; #undef GLchar diff --git a/src/gui/opengl/qopenglprogrambinarycache_p.h b/src/gui/opengl/qopenglprogrambinarycache_p.h index 0553121a22..6a636fcf56 100644 --- a/src/gui/opengl/qopenglprogrambinarycache_p.h +++ b/src/gui/opengl/qopenglprogrambinarycache_p.h @@ -20,7 +20,7 @@ #include <QtCore/qmutex.h> #include <QtCore/QLoggingCategory> #include <QtGui/private/qopenglcontext_p.h> -#include <QtGui/private/qshader_p.h> +#include <rhi/qshader.h> QT_BEGIN_NAMESPACE @@ -28,7 +28,7 @@ QT_BEGIN_NAMESPACE // therefore stay independent from QOpenGLShader(Program). Must rely only on // QOpenGLContext/Functions. -Q_GUI_EXPORT Q_DECLARE_LOGGING_CATEGORY(lcOpenGLProgramDiskCache) +QT_DECLARE_EXPORTED_QT_LOGGING_CATEGORY(lcOpenGLProgramDiskCache, Q_GUI_EXPORT) class Q_GUI_EXPORT QOpenGLProgramBinaryCache { diff --git a/src/gui/opengl/qt_attribution.json b/src/gui/opengl/qt_attribution.json index d3ff10d803..44310980e2 100644 --- a/src/gui/opengl/qt_attribution.json +++ b/src/gui/opengl/qt_attribution.json @@ -5,7 +5,7 @@ "QDocModule": "qtgui", "Description": "OpenGL header generated from the Khronos OpenGL / OpenGL ES XML API Registry.", "QtUsage": "Used on Windows and Linux in the OpenGL related headers of Qt GUI.", - "Path": "qopenglext.h", + "Files": "qopenglext.h", "Homepage": "https://www.khronos.org/", "Version": "Revision 27684", @@ -20,7 +20,7 @@ "QDocModule": "qtgui", "Description": "OpenGL ES 2 header generated from the Khronos OpenGL / OpenGL ES XML API Registry.", "QtUsage": "Used on Windows and Linux in the OpenGL related headers of Qt GUI.", - "Path": "qopengles2ext.h", + "Files": "qopengles2ext.h", "Homepage": "https://www.khronos.org/", "Version": "Revision 27673", |