diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 6c1f6567..2ad975ae 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -181,8 +181,13 @@ static inline void kgem_bo_submit(struct kgem *kgem, struct kgem_bo *bo) void __kgem_flush(struct kgem *kgem, struct kgem_bo *bo); static inline void kgem_bo_flush(struct kgem *kgem, struct kgem_bo *bo) { + if (!bo->needs_flush) + return; + kgem_bo_submit(kgem, bo); __kgem_flush(kgem, bo); + + bo->needs_flush = false; } static inline struct kgem_bo *kgem_bo_reference(struct kgem_bo *bo) diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 1586884b..b3b3185e 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -1787,6 +1787,12 @@ sna_do_pageflip(struct sna *sna, sna->mode.fb_pixmap = pixmap->drawable.serialNumber; bo->cpu_read = bo->cpu_write = false; bo->gpu = true; + + /* Although the kernel performs an implicit flush upon + * page-flipping, marking the bo as requiring a flush + * here ensures that the buffer goes into the active cache + * upon release. + */ bo->needs_flush = true; } else { drmModeRmFB(sna->kgem.fd, mode->fb_id);