[mutter] cogl: Add a quirk on Mali to glFlush before glGenerateMipmap



commit f1d7ccfa7943dbe1157a331d1cfce4440c7e2af2
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Tue Sep 6 09:29:26 2022 +0000

    cogl: Add a quirk on Mali to glFlush before glGenerateMipmap
    
    But only when the texture in question has associated framebuffers that
    actually need flushing.
    
    Workaround for: https://github.com/Xilinx/mali-userspace-binaries/issues/3
    Related to: https://gitlab.gnome.org/GNOME/mutter/-/issues/2354
    
    Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2614>

 cogl/cogl/cogl-private.h                    | 3 +++
 cogl/cogl/cogl-texture-2d.c                 | 4 ++++
 cogl/cogl/driver/gl/gles/cogl-driver-gles.c | 7 +++++++
 3 files changed, 14 insertions(+)
---
diff --git a/cogl/cogl/cogl-private.h b/cogl/cogl/cogl-private.h
index 2878a16403..5a714fc1ab 100644
--- a/cogl/cogl/cogl-private.h
+++ b/cogl/cogl/cogl-private.h
@@ -67,6 +67,9 @@ typedef enum
    */
   COGL_PRIVATE_FEATURE_ANY_GL,
 
+  /* This is a Mali bug/quirk: */
+  COGL_PRIVATE_QUIRK_GENERATE_MIPMAP_NEEDS_FLUSH,
+
   COGL_N_PRIVATE_FEATURES
 } CoglPrivateFeature;
 
diff --git a/cogl/cogl/cogl-texture-2d.c b/cogl/cogl/cogl-texture-2d.c
index 07ab820740..88978abb3d 100644
--- a/cogl/cogl/cogl-texture-2d.c
+++ b/cogl/cogl/cogl-texture-2d.c
@@ -403,6 +403,10 @@ _cogl_texture_2d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
        */
       _cogl_texture_flush_journal_rendering (tex);
 
+      if (_cogl_has_private_feature (ctx, COGL_PRIVATE_QUIRK_GENERATE_MIPMAP_NEEDS_FLUSH) &&
+          _cogl_texture_get_associated_framebuffers (tex))
+        ctx->glFlush ();
+
       ctx->driver_vtable->texture_2d_generate_mipmap (tex_2d);
 
       tex_2d->mipmaps_dirty = FALSE;
diff --git a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
index 00f72fbab9..de080a99db 100644
--- a/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
+++ b/cogl/cogl/driver/gl/gles/cogl-driver-gles.c
@@ -440,6 +440,13 @@ _cogl_driver_update_features (CoglContext *context,
   if (context->glGenQueries && context->glQueryCounter && context->glGetInteger64v)
     COGL_FLAGS_SET (context->features, COGL_FEATURE_ID_TIMESTAMP_QUERY, TRUE);
 
+  if (!g_strcmp0 ((char *) context->glGetString (GL_RENDERER), "Mali-400 MP"))
+    {
+      COGL_FLAGS_SET (private_features,
+                      COGL_PRIVATE_QUIRK_GENERATE_MIPMAP_NEEDS_FLUSH,
+                      TRUE);
+    }
+
   /* Cache features */
   for (i = 0; i < G_N_ELEMENTS (private_features); i++)
     context->private_features[i] |= private_features[i];


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]