From 9ea242c275a70351abcfbc0f8f3233c122abecbe Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sun, 9 Nov 2014 08:59:08 +0000 Subject: [PATCH] sna: Check picture format on destination before beginning a GPU operation This is more important in the multiple stage operations like glyph rendering where we do not want to initiate an operation on the GPU only then to fallback due to an incompatible destination. Signed-off-by: Chris Wilson --- src/sna/sna_composite.c | 8 ++++---- src/sna/sna_glyphs.c | 8 ++++---- src/sna/sna_render_inline.h | 24 ++++++++++++++++++++++++ 3 files changed, 32 insertions(+), 8 deletions(-) diff --git a/src/sna/sna_composite.c b/src/sna/sna_composite.c index d19dc42e..f01f020e 100644 --- a/src/sna/sna_composite.c +++ b/src/sna/sna_composite.c @@ -696,8 +696,8 @@ sna_composite(CARD8 op, goto fallback; } - if (dst->alphaMap) { - DBG(("%s: fallback due to unhandled alpha-map\n", __FUNCTION__)); + if (!can_render_to_picture(dst)) { + DBG(("%s: fallback due to unhandled picture\n", __FUNCTION__)); goto fallback; } @@ -956,8 +956,8 @@ sna_composite_rectangles(CARD8 op, if (wedged(sna)) goto fallback; - if (dst->alphaMap) { - DBG(("%s: fallback, dst has an alpha-map\n", __FUNCTION__)); + if (!can_render_to_picture(dst)) { + DBG(("%s: fallback, dst has an incompatible picture\n", __FUNCTION__)); goto fallback; } diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c index a4052c6e..a5dfb06b 100644 --- a/src/sna/sna_glyphs.c +++ b/src/sna/sna_glyphs.c @@ -1971,8 +1971,8 @@ sna_glyphs(CARD8 op, goto fallback; } - if (dst->alphaMap) { - DBG(("%s: fallback -- dst alpha map\n", __FUNCTION__)); + if (!can_render_to_picture(dst)) { + DBG(("%s: fallback -- dst incompatible picture\n", __FUNCTION__)); goto fallback; } @@ -2301,8 +2301,8 @@ sna_glyphs__shared(CARD8 op, goto fallback; } - if (dst->alphaMap) { - DBG(("%s: fallback -- dst alpha map\n", __FUNCTION__)); + if (!can_render_to_picture(dst)) { + DBG(("%s: fallback -- incompatible picture\n", __FUNCTION__)); goto fallback; } diff --git a/src/sna/sna_render_inline.h b/src/sna/sna_render_inline.h index 3d24c5c8..10fbbfe2 100644 --- a/src/sna/sna_render_inline.h +++ b/src/sna/sna_render_inline.h @@ -112,6 +112,30 @@ too_small(struct sna_pixmap *priv) return (priv->create & KGEM_CAN_CREATE_GPU) == 0; } +static inline bool +can_render_to_picture(PicturePtr dst) +{ + if (dst->alphaMap) { + DBG(("%s(pixmap=%ld) -- no, has alphamap\n", __FUNCTION__, + get_drawable_pixmap(dst->pDrawable)->drawable.serialNumber)); + return false; + } + + switch (PICT_FORMAT_TYPE(dst->format)) { + case PICT_TYPE_COLOR: + case PICT_TYPE_GRAY: + case PICT_TYPE_OTHER: + DBG(("%s(pixmap=%ld) -- no, has palette\n", __FUNCTION__, + get_drawable_pixmap(dst->pDrawable)->drawable.serialNumber)); + return false; + default: + break; + } + + return true; +} + + static inline bool is_gpu_dst(struct sna_pixmap *priv) {