From 08b33ba8f12bb4bc425ca1bc40e2660e446e2c65 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Thu, 30 May 2013 14:57:56 +0100 Subject: [PATCH] sna: Assert that an existing scanout is the desired size Signed-off-by: Chris Wilson --- src/sna/sna_display.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c index 6cade448..3231ca03 100644 --- a/src/sna/sna_display.c +++ b/src/sna/sna_display.c @@ -145,6 +145,25 @@ uint32_t sna_crtc_to_plane(xf86CrtcPtr crtc) return to_sna_crtc(crtc)->plane; } +#ifndef NDEBUG +static void gem_close(int fd, uint32_t handle); +static void assert_scanout(struct kgem *kgem, struct kgem_bo *bo, + int width, int height) +{ + struct drm_mode_fb_cmd info; + + assert(bo->scanout); + + VG_CLEAR(info); + info.fb_id = bo->delta; + + assert(drmIoctl(kgem->fd, DRM_IOCTL_MODE_GETFB, &info) == 0); + gem_close(kgem->fd, info.handle); + + assert(width == info.width && height == info.height); +} +#endif + static unsigned get_fb(struct sna *sna, struct kgem_bo *bo, int width, int height) { @@ -157,6 +176,7 @@ static unsigned get_fb(struct sna *sna, struct kgem_bo *bo, if (bo->delta) { DBG(("%s: reusing fb=%d for handle=%d\n", __FUNCTION__, bo->delta, bo->handle)); + assert_scanout(&sna->kgem, bo, width, height); return bo->delta; }