summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel van Vugt <daniel.van.vugt@canonical.com>2020-07-02 17:58:30 +0800
committerDaniel van Vugt <daniel.van.vugt@canonical.com>2020-07-07 16:15:24 +0800
commit3a474556b8cda1cc12b128125689fa393d5c1c0b (patch)
tree06f199fc00fe4076064a25596f8e25b098231a69
parent249274c67705614fa14c95808283d14a38302fba (diff)
downloadmutter-3a474556b8cda1cc12b128125689fa393d5c1c0b.tar.gz
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
-rw-r--r--cogl/cogl/cogl-texture-2d.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/cogl/cogl/cogl-texture-2d.c b/cogl/cogl/cogl-texture-2d.c
index a99cbb31e..bababf749 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;