From dadffd0061e2b14db397608e3cedfe9c76e546c8 Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Thu, 11 Oct 2012 14:30:29 +1000 Subject: [PATCH] intel: fix fullscreen damage posting on pageflip While playing with MPX and sw cursor I noticed page flips won't end up misrendering some bits, so the sw cursor was replacing the bits on the wrong pixmap. Fix the damage handling to be correct and append damage before swapping the pointers and process damage after. This fixes misrendering with MPX cursors under a fullscreen compositor, that pageflips. Signed-off-by: Dave Airlie [ickle: The secret is that damage is sometimes reported before the rendering in DamageRegionAppend, and sometimes afterwards in DamageRegionProcessPending. For instance, the software cursor operates prior to being rendered over.] Signed-off-by: Chris Wilson --- src/intel_dri.c | 25 ++++++++++++------------- src/sna/sna_dri.c | 30 ++++++++++++++++-------------- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/src/intel_dri.c b/src/intel_dri.c index 64cb5678..867a4653 100644 --- a/src/intel_dri.c +++ b/src/intel_dri.c @@ -725,6 +725,17 @@ static struct intel_pixmap * intel_exchange_pixmap_buffers(struct intel_screen_private *intel, PixmapPtr front, PixmapPtr back) { struct intel_pixmap *new_front, *new_back; + RegionRec region; + + /* Post damage on the front buffer so that listeners, such + * as DisplayLink know take a copy and shove it over the USB. + * also for sw cursors. + */ + region.extents.x1 = region.extents.y1 = 0; + region.extents.x2 = front->drawable.width; + region.extents.y2 = front->drawable.height; + region.data = NULL; + DamageRegionAppend(&front->drawable, ®ion); new_front = intel_get_pixmap_private(back); new_back = intel_get_pixmap_private(front); @@ -735,19 +746,7 @@ intel_exchange_pixmap_buffers(struct intel_screen_private *intel, PixmapPtr fron intel_glamor_exchange_buffers(intel, front, back); - /* Post damage on the new front buffer so that listeners, such - * as DisplayLink know take a copy and shove it over the USB. - */ - { - RegionRec region; - - region.extents.x1 = region.extents.y1 = 0; - region.extents.x2 = front->drawable.width; - region.extents.y2 = front->drawable.height; - region.data = NULL; - DamageRegionAppend(&front->drawable, ®ion); - DamageRegionProcessPending(&front->drawable); - } + DamageRegionProcessPending(&front->drawable); return new_front; } diff --git a/src/sna/sna_dri.c b/src/sna/sna_dri.c index 2fc3af25..15ac46a3 100644 --- a/src/sna/sna_dri.c +++ b/src/sna/sna_dri.c @@ -430,6 +430,16 @@ static void set_bo(PixmapPtr pixmap, struct kgem_bo *bo) struct sna_pixmap *priv = sna_pixmap(pixmap); RegionRec region; + /* Post damage on the new front buffer so that listeners, such + * as DisplayLink know take a copy and shove it over the USB, + * also for software cursors and the like. + */ + region.extents.x1 = region.extents.y1 = 0; + region.extents.x2 = pixmap->drawable.width; + region.extents.y2 = pixmap->drawable.height; + region.data = NULL; + DamageRegionAppend(&pixmap->drawable, ®ion); + sna_damage_all(&priv->gpu_damage, pixmap->drawable.width, pixmap->drawable.height); @@ -446,14 +456,6 @@ static void set_bo(PixmapPtr pixmap, struct kgem_bo *bo) if (bo->domain != DOMAIN_GPU) bo->domain = DOMAIN_NONE; - /* Post damage on the new front buffer so that listeners, such - * as DisplayLink know take a copy and shove it over the USB. - */ - region.extents.x1 = region.extents.y1 = 0; - region.extents.x2 = pixmap->drawable.width; - region.extents.y2 = pixmap->drawable.height; - region.data = NULL; - DamageRegionAppend(&pixmap->drawable, ®ion); DamageRegionProcessPending(&pixmap->drawable); } @@ -618,15 +620,17 @@ sna_dri_copy_to_front(struct sna *sna, DrawablePtr draw, RegionPtr region, boxes = &clip.extents; n = 1; } + pixman_region_translate(region, dx, dy); + DamageRegionAppend(&pixmap->drawable, region); if (wedged(sna)) { sna_dri_copy_fallback(sna, draw->bitsPerPixel, - src_bo, -draw->x, -draw->y, - dst_bo, dx, dy, + src_bo, -draw->x-dx, -draw->y-dy, + dst_bo, 0, 0, boxes, n); } else { sna->render.copy_boxes(sna, GXcopy, - (PixmapPtr)draw, src_bo, -draw->x, -draw->y, - pixmap, dst_bo, dx, dy, + (PixmapPtr)draw, src_bo, -draw->x-dx, -draw->y-dy, + pixmap, dst_bo, 0, 0, boxes, n, COPY_LAST); DBG(("%s: flushing? %d\n", __FUNCTION__, flush)); @@ -637,8 +641,6 @@ sna_dri_copy_to_front(struct sna *sna, DrawablePtr draw, RegionPtr region, } } - pixman_region_translate(region, dx, dy); - DamageRegionAppend(&pixmap->drawable, region); DamageRegionProcessPending(&pixmap->drawable); if (clip.data)