From 684e921a5442c0d7afedd27b7b85719d8195c6ee Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 22 Jan 2015 15:26:00 +0000 Subject: [PATCH] sna/dri2: Only preserve back buffers with the same pitch We can only pageflip if we don't change the pitch, otherwise we simulate the pageflip with modeset. The idea is that once we have exchanged the buffers, we will quickly settle down to a steady state scenario where each buffer has the same pitch. We can encourage this further by only keeping those buffers around that do have the same pitch as the current front. Signed-off-by: Chris Wilson --- src/sna/sna_dri2.c | 32 ++++++++++++++++++-------------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/src/sna/sna_dri2.c b/src/sna/sna_dri2.c index 6b0520f..8bbb598d 100644 --- a/src/sna/sna_dri2.c +++ b/src/sna/sna_dri2.c @@ -82,6 +82,18 @@ get_private(void *buffer) return (struct sna_dri2_private *)((DRI2Buffer2Ptr)buffer+1); } +pure static inline DRI2BufferPtr sna_pixmap_get_buffer(PixmapPtr pixmap) +{ + assert(pixmap->refcnt); + return ((void **)__get_private(pixmap, sna_pixmap_key))[2]; +} + +static inline void sna_pixmap_set_buffer(PixmapPtr pixmap, void *ptr) +{ + assert(pixmap->refcnt); + ((void **)__get_private(pixmap, sna_pixmap_key))[2] = ptr; +} + #if DRI2INFOREC_VERSION >= 4 enum event_type { WAITMSC = 0, @@ -138,10 +150,14 @@ sna_dri2_get_back(struct sna *sna, int flags; bool reuse; - DBG(("%s: draw size=%dx%d, buffer size=%dx%d\n", + DBG(("%s: draw size=%dx%d, buffer size=%dx%d, is-scanout? %d, pitch=%d, front pitch=%d\n", __FUNCTION__, draw->width, draw->height, - get_private(back)->size & 0xffff, get_private(back)->size >> 16)); + get_private(back)->size & 0xffff, get_private(back)->size >> 16, + get_private(back)->bo->scanout, + back->pitch, sna_pixmap_get_buffer(get_drawable_pixmap(draw))->pitch )); reuse = (draw->height << 16 | draw->width) == get_private(back)->size; + if (reuse && get_private(back)->bo->scanout) + reuse = sna_pixmap_get_buffer(get_drawable_pixmap(draw))->pitch == back->pitch; if (reuse) { bo = get_private(back)->bo; assert(bo->refcnt); @@ -401,18 +417,6 @@ static struct kgem_bo *sna_pixmap_set_dri(struct sna *sna, return priv->gpu_bo; } -pure static inline void *sna_pixmap_get_buffer(PixmapPtr pixmap) -{ - assert(pixmap->refcnt); - return ((void **)__get_private(pixmap, sna_pixmap_key))[2]; -} - -static inline void sna_pixmap_set_buffer(PixmapPtr pixmap, void *ptr) -{ - assert(pixmap->refcnt); - ((void **)__get_private(pixmap, sna_pixmap_key))[2] = ptr; -} - void sna_dri2_pixmap_update_bo(struct sna *sna, PixmapPtr pixmap, struct kgem_bo *bo) { -- 2.1.4