sna: Assert that an existing scanout is the desired size

Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
This commit is contained in:
Chris Wilson 2013-05-30 14:57:56 +01:00
parent a9acc8dbb4
commit 08b33ba8f1
1 changed files with 20 additions and 0 deletions

View File

@ -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;
}