From 568da29fbfdaa56d8a9f91d4bfa4c8100b5d802c Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Wed, 28 Feb 2024 13:44:24 +0100 Subject: [PATCH] opengl: move pack invert detection to OpenGlContext --- src/opengl/glplatform.cpp | 4 ---- src/opengl/glplatform.h | 6 ------ src/opengl/openglcontext.cpp | 6 ++++++ src/opengl/openglcontext.h | 2 ++ src/plugins/screencast/screencastutils.h | 5 +++-- 5 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/opengl/glplatform.cpp b/src/opengl/glplatform.cpp index 83d6c6a36f..9724550bcd 100644 --- a/src/opengl/glplatform.cpp +++ b/src/opengl/glplatform.cpp @@ -719,7 +719,6 @@ GLPlatform::GLPlatform() , m_chipClass(UnknownChipClass) , m_recommendedCompositor(QPainterCompositing) , m_looseBinding(false) - , m_packInvert(false) , m_virtualMachine(false) , m_preferBufferSubData(false) , m_platformInterface(NoOpenGLPlatformInterface) @@ -748,7 +747,6 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) m_chipset = QByteArrayLiteral("Unknown"); m_preferBufferSubData = false; - m_packInvert = m_context->hasOpenglExtension("GL_MESA_pack_invert"); // Mesa classic drivers // ==================================================== @@ -1061,8 +1059,6 @@ bool GLPlatform::supports(GLFeature feature) const switch (feature) { case GLFeature::LooseBinding: return m_looseBinding; - case GLFeature::PackInvert: - return m_packInvert; case GLFeature::TimerQuery: return m_context && m_context->supportsTimerQueries(); } diff --git a/src/opengl/glplatform.h b/src/opengl/glplatform.h index 9900829749..fc6147f86b 100644 --- a/src/opengl/glplatform.h +++ b/src/opengl/glplatform.h @@ -31,11 +31,6 @@ enum class GLFeature { */ LooseBinding, - /** - * Set if the extension GL_MESA_pack_invert is present - */ - PackInvert, - /** * Set if the driver supports GL_ARB_timer_query extension or OpenGL 3.3. */ @@ -383,7 +378,6 @@ private: Version m_mesaVersion; Version m_driverVersion; bool m_looseBinding : 1; - bool m_packInvert : 1; bool m_virtualMachine : 1; bool m_preferBufferSubData : 1; OpenGLPlatformInterface m_platformInterface; diff --git a/src/opengl/openglcontext.cpp b/src/opengl/openglcontext.cpp index b8195df670..1c25cb07a2 100644 --- a/src/opengl/openglcontext.cpp +++ b/src/opengl/openglcontext.cpp @@ -90,6 +90,7 @@ OpenGlContext::OpenGlContext() , m_haveBufferStorage((!m_isOpenglES || hasVersion(Version(4, 4))) || hasOpenglExtension(QByteArrayLiteral("GL_ARB_buffer_storage")) || hasOpenglExtension(QByteArrayLiteral("GL_EXT_buffer_storage"))) , m_haveSyncFences((m_isOpenglES && hasVersion(Version(3, 0))) || (!m_isOpenglES && hasVersion(Version(3, 2))) || hasOpenglExtension(QByteArrayLiteral("GL_ARB_sync"))) , m_supportsIndexedQuads(checkIndexedQuads(this)) + , m_supportsPackInvert(hasOpenglExtension(QByteArrayLiteral("GL_MESA_pack_invert"))) { } @@ -209,6 +210,11 @@ bool OpenGlContext::haveSyncFences() const return m_haveSyncFences; } +bool OpenGlContext::supportsPackInvert() const +{ + return m_supportsPackInvert; +} + ShaderManager *OpenGlContext::shaderManager() const { return m_shaderManager; diff --git a/src/opengl/openglcontext.h b/src/opengl/openglcontext.h index fddbffa580..118301dca4 100644 --- a/src/opengl/openglcontext.h +++ b/src/opengl/openglcontext.h @@ -51,6 +51,7 @@ public: bool hasMapBufferRange() const; bool haveBufferStorage() const; bool haveSyncFences() const; + bool supportsPackInvert() const; ShaderManager *shaderManager() const; GLVertexBuffer *streamingVbo() const; IndexBuffer *indexBuffer() const; @@ -91,6 +92,7 @@ protected: const bool m_haveBufferStorage; const bool m_haveSyncFences; const bool m_supportsIndexedQuads; + const bool m_supportsPackInvert; ShaderManager *m_shaderManager = nullptr; GLVertexBuffer *m_streamingBuffer = nullptr; IndexBuffer *m_indexBuffer = nullptr; diff --git a/src/plugins/screencast/screencastutils.h b/src/plugins/screencast/screencastutils.h index b6a6dccb6a..0228146c15 100644 --- a/src/plugins/screencast/screencastutils.h +++ b/src/plugins/screencast/screencastutils.h @@ -49,9 +49,10 @@ static GLenum closestGLType(spa_video_format format) static void doGrabTexture(GLTexture *texture, spa_data *spa, spa_video_format format) { + const auto context = OpenGlContext::currentContext(); const QSize size = texture->size(); - const bool invertNeeded = GLPlatform::instance()->isGLES() ^ (texture->contentTransform() != OutputTransform::FlipY); - const bool invertNeededAndSupported = invertNeeded && GLPlatform::instance()->supports(GLFeature::PackInvert); + const bool invertNeeded = context->isOpenglES() ^ (texture->contentTransform() != OutputTransform::FlipY); + const bool invertNeededAndSupported = invertNeeded && context->supportsPackInvert(); GLboolean prev; if (invertNeededAndSupported) { glGetBooleanv(GL_PACK_INVERT_MESA, &prev);