[mutter] cogl-texture-2d: Flush the journal before mipmapping



commit 3a474556b8cda1cc12b128125689fa393d5c1c0b
Author: Daniel van Vugt <daniel van vugt canonical com>
Date:   Thu Jul 2 17:58:30 2020 +0800

    cogl-texture-2d: Flush the journal before mipmapping
    
    In the case of indirect rendering like the first frame to use mutter's
    background wallpaper:
    
      Texture_A -> FBO_B (Texture_B) -> FBO_C (screen)
    
    we would be trying to render the contents of both FBO_B and FBO_C in
    the same flush, before the contents of Texture_A had made it to FBO_B.
    So when FBO_C wants to use mipmaps of Texture_B they didn't exist yet
    and appeared all black. And the blackness would remain for subsequent
    frames as cogl has now decided the mipmaps of FBO_B are no longer
    "dirty" and don't need refreshing:
    
      FBO_B (Texture_B) (mipmaps_dirty==FALSE but black) -> FBO_C (screen)
    
    We must flush FBO_B before referencing Texture_B for use in rendering
    FBO_C. This only happens when Texture_A changes (e.g. when the user
    changes their background wallpaper) so there's no ongoing performance
    penalty from this flush.
    
    https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1347

 cogl/cogl/cogl-texture-2d.c | 5 +++++
 1 file changed, 5 insertions(+)
---
diff --git a/cogl/cogl/cogl-texture-2d.c b/cogl/cogl/cogl-texture-2d.c
index a99cbb31e4..bababf749c 100644
--- a/cogl/cogl/cogl-texture-2d.c
+++ b/cogl/cogl/cogl-texture-2d.c
@@ -402,6 +402,11 @@ _cogl_texture_2d_pre_paint (CoglTexture *tex, CoglTexturePrePaintFlags flags)
     {
       CoglContext *ctx = tex->context;
 
+      /* Since we are about to ask the GPU to generate mipmaps of tex, we
+       * better make sure tex is up-to-date.
+       */
+      _cogl_texture_flush_journal_rendering (tex);
+
       ctx->driver_vtable->texture_2d_generate_mipmap (tex_2d);
 
       tex_2d->mipmaps_dirty = FALSE;


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