From 4a447c514b3193897e0d3ec4b3cf75f346d7438e Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 16 Jul 2013 08:58:21 +0100 Subject: [PATCH] sna: Create a pixmap in ordinary system memory for depth=1 uploads Since we will not sample depth=1 pixmaps from the GPU, we may as well directly allocate these in system memory and avoid tickling the upload cache. This then avoids an issue within the size calculation code which makes the assumption that bpp>=8. Reported-by: Jiri Slaby Signed-off-by: Chris Wilson --- src/sna/sna_accel.c | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 2eb16992..fa28b6db 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -3449,7 +3449,6 @@ sna_pixmap_create_upload(ScreenPtr screen, struct sna *sna = to_sna_from_screen(screen); PixmapPtr pixmap; struct sna_pixmap *priv; - int bpp = bits_per_pixel(depth); void *ptr; DBG(("%s(%d, %d, %d, flags=%x)\n", __FUNCTION__, @@ -3457,6 +3456,10 @@ sna_pixmap_create_upload(ScreenPtr screen, assert(width); assert(height); + if (depth == 1) + return create_pixmap(sna, screen, width, height, depth, + CREATE_PIXMAP_USAGE_SCRATCH); + if (sna->freed_pixmap) { pixmap = sna->freed_pixmap; sna->freed_pixmap = pixmap->devPrivate.ptr; @@ -3477,11 +3480,17 @@ sna_pixmap_create_upload(ScreenPtr screen, sna_set_pixmap(pixmap, priv); } + pixmap->drawable.width = width; + pixmap->drawable.height = height; + pixmap->drawable.depth = depth; + pixmap->drawable.bitsPerPixel = bits_per_pixel(depth); + priv = _sna_pixmap_reset(pixmap); priv->header = true; priv->gpu_bo = kgem_create_buffer_2d(&sna->kgem, - width, height, bpp, + width, height, + pixmap->drawable.bitsPerPixel, flags, &ptr); if (!priv->gpu_bo) { free(priv); @@ -3497,11 +3506,6 @@ sna_pixmap_create_upload(ScreenPtr screen, sna_damage_all(&priv->gpu_damage, width, height); sna_damage_all(&priv->cpu_damage, width, height); - pixmap->drawable.width = width; - pixmap->drawable.height = height; - pixmap->drawable.depth = depth; - pixmap->drawable.bitsPerPixel = bpp; - pixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER; pixmap->devKind = priv->gpu_bo->pitch; pixmap->devPrivate.ptr = ptr;