From c81dba18e6a308d716a11b90da6e53ca7f5f8a02 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 13 Jan 2012 14:21:13 +0000 Subject: sna: Hint whether we prefer to use the GPU for a pixmap This includes the condition where the pixmap is too large, as well as being too small, to be allocatable on the GPU. It is only a hint set during creation, and may be overridden if required. This fixes the regression in ocitysmap which decided to render glyphs into a GPU mask for a destination that does not fit into the aperture. Signed-off-by: Chris Wilson --- src/sna/sna.h | 1 + src/sna/sna_accel.c | 1 + src/sna/sna_render_inline.h | 13 ++++++++++++- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/src/sna/sna.h b/src/sna/sna.h index 76e32997..6f726981 100644 --- a/src/sna/sna.h +++ b/src/sna/sna.h @@ -145,6 +145,7 @@ struct sna_pixmap { uint8_t pinned :1; uint8_t mapped :1; uint8_t flush :1; + uint8_t gpu :1; uint8_t header :1; }; diff --git a/src/sna/sna_accel.c b/src/sna/sna_accel.c index 2d6d1ee4..0c7ab575 100644 --- a/src/sna/sna_accel.c +++ b/src/sna/sna_accel.c @@ -690,6 +690,7 @@ static PixmapPtr sna_create_pixmap(ScreenPtr screen, } priv->stride = pad; + priv->gpu = true; } return pixmap; diff --git a/src/sna/sna_render_inline.h b/src/sna/sna_render_inline.h index ca8e8391..ee55db7d 100644 --- a/src/sna/sna_render_inline.h +++ b/src/sna/sna_render_inline.h @@ -90,7 +90,18 @@ is_cpu(DrawablePtr drawable) static inline Bool too_small(DrawablePtr drawable) { - return ((uint32_t)drawable->width * drawable->height * drawable->bitsPerPixel <= 8*4096) && !is_gpu(drawable); + struct sna_pixmap *priv = sna_pixmap_from_drawable(drawable); + + if (priv == NULL) + return true; + + if (priv->gpu_damage) + return false; + + if (priv->cpu_bo && kgem_bo_is_busy(priv->cpu_bo)) + return false; + + return !priv->gpu; } static inline Bool -- cgit v1.2.3