From a1f30f5b9b54f460aa1472334f03d543c843b6ae Mon Sep 17 00:00:00 2001 From: Matthew Waters Date: Mon, 9 May 2022 16:21:55 +1000 Subject: [PATCH] gl/context: disable timer queries for ARM Mali-G52 Performing a timer query with a default framebuffer that is incomplete (from using a surfaceless context) will produce GL errors. Disable the timer query on this platform to avoid the errors. Part-of: --- .../gst-libs/gst/gl/gstglcontext.c | 12 +-- .../gst-libs/gst/gl/gstglcontext_private.h | 3 + .../gst-libs/gst/gl/gstglcontextquirks.c | 94 +++++++++++++++++++ .../gst-libs/gst/gl/meson.build | 1 + 4 files changed, 99 insertions(+), 11 deletions(-) create mode 100644 subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontextquirks.c diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontext.c b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontext.c index 4e7fe91875..4aab1a579a 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontext.c +++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontext.c @@ -1530,17 +1530,7 @@ gst_gl_context_fill_info (GstGLContext * context, GError ** error) goto failure; } - /* Does not implement OES_vertex_array_object properly, see - * https://bugzilla.gnome.org/show_bug.cgi?id=750185 */ - if (g_strcmp0 ((const gchar *) gl->GetString (GL_VENDOR), - "Imagination Technologies") == 0 - && g_strcmp0 ((const gchar *) gl->GetString (GL_RENDERER), - "PowerVR SGX 544MP") == 0) { - gl->GenVertexArrays = NULL; - gl->DeleteVertexArrays = NULL; - gl->BindVertexArray = NULL; - gl->IsVertexArray = NULL; - } + gst_gl_context_apply_quirks (context); if (GST_IS_GL_WRAPPED_CONTEXT (context)) { /* XXX: vfunc? */ diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontext_private.h b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontext_private.h index 2fa8cfdf2d..0fe1c22f5f 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontext_private.h +++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontext_private.h @@ -29,6 +29,9 @@ G_GNUC_INTERNAL extern GstDebugCategory *gst_gl_context_debug; G_GNUC_INTERNAL gboolean _gst_gl_context_debug_is_enabled (GstGLContext * context); +G_GNUC_INTERNAL +void gst_gl_context_apply_quirks (GstGLContext * context); + #define GST_GL_CONTEXT_WRAPPED_GL_CONFIG_NAME "gst.gl.context.wrapped.config" #define GST_TYPE_GL_WRAPPED_CONTEXT (gst_gl_wrapped_context_get_type()) diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontextquirks.c b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontextquirks.c new file mode 100644 index 0000000000..3a0085ad44 --- /dev/null +++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/gstglcontextquirks.c @@ -0,0 +1,94 @@ +/* + * GStreamer + * Copyright (C) 2022 Matthew Waters + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Library General Public + * License as published by the Free Software Foundation; either + * version 2 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Library General Public License for more details. + * + * You should have received a copy of the GNU Library General Public + * License along with this library; if not, write to the + * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor, + * Boston, MA 02110-1301, USA. + */ + +#ifdef HAVE_CONFIG_H +# include "config.h" +#endif + +#include +#include +#include "gstglfuncs.h" + +#define GST_CAT_DEFAULT gst_gl_context_debug + +#ifndef GL_FRAMEBUFFER_BINDING +#define GL_FRAMEBUFFER_BINDING 0x8CA6 +#endif +#ifndef GL_FRAMEBUFFER +#define GL_FRAMEBUFFER 0x8D40 +#endif +#ifndef GL_FRAMEBUFFER_COMPLETE +#define GL_FRAMEBUFFER_COMPLETE 0x8CD5 +#endif + +void +gst_gl_context_apply_quirks (GstGLContext * context) +{ + GstGLFuncs *gl = context->gl_vtable; + const char *gl_vendor, *gl_renderer; + + gl_vendor = (const char *) gl->GetString (GL_VENDOR); + gl_renderer = (const char *) gl->GetString (GL_RENDERER); + + /* Does not implement OES_vertex_array_object properly, see + * https://bugzilla.gnome.org/show_bug.cgi?id=750185 */ + if (g_strcmp0 (gl_vendor, "Imagination Technologies") == 0 + && g_strcmp0 (gl_renderer, "PowerVR SGX 544MP") == 0) { + gl->GenVertexArrays = NULL; + gl->DeleteVertexArrays = NULL; + gl->BindVertexArray = NULL; + gl->IsVertexArray = NULL; + } + /* doesn't support timer queries without a complete framebuffer. + * If the default framebuffer is backed by a surfaceless context, then the + * default framebuffer is always incomplete and timer queries to time + * upload/downloads will fail with GL errors. */ + if (g_strcmp0 (gl_vendor, "ARM") == 0 + && g_strcmp0 (gl_renderer, "Mali-G52") == 0 + && gl->CheckFramebufferStatus) { + gint current_fbo; + GLenum fbo_ret; + + gl->GetIntegerv (GL_FRAMEBUFFER_BINDING, ¤t_fbo); + if (current_fbo != 0) + gl->BindFramebuffer (GL_FRAMEBUFFER, 0); + + fbo_ret = gl->CheckFramebufferStatus (GL_FRAMEBUFFER); + if (fbo_ret != GL_FRAMEBUFFER_COMPLETE) { + GST_FIXME_OBJECT (context, "default framebuffer is not complete " + "(is 0x%x) on ARM Mali-G52 which doesn't support timer queries with " + "an incomplete framebuffer object, disabling timer queries", fbo_ret); + gl->GenQueries = NULL; + gl->BeginQuery = NULL; + gl->EndQuery = NULL; + gl->QueryCounter = NULL; + gl->DeleteQueries = NULL; + gl->IsQuery = NULL; + gl->GetQueryiv = NULL; + gl->GetQueryObjectiv = NULL; + gl->GetQueryObjectuiv = NULL; + gl->GetQueryObjecti64v = NULL; + gl->GetQueryObjectui64v = NULL; + } + + if (current_fbo != 0) + gl->BindFramebuffer (GL_FRAMEBUFFER, current_fbo); + } +} diff --git a/subprojects/gst-plugins-base/gst-libs/gst/gl/meson.build b/subprojects/gst-plugins-base/gst-libs/gst/gl/meson.build index f7286a01eb..8b190cb891 100644 --- a/subprojects/gst-plugins-base/gst-libs/gst/gl/meson.build +++ b/subprojects/gst-plugins-base/gst-libs/gst/gl/meson.build @@ -20,6 +20,7 @@ gl_sources = files([ 'gstglbufferpool.c', 'gstglcontext.c', 'gstglcontextconfig.c', + 'gstglcontextquirks.c', 'gstgldebug.c', 'gstgldisplay.c', 'gstglfeature.c', -- 2.34.1