From f6ca94e8acb9124f04549176114c76cd2d20b943 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 6 Jun 2014 08:30:59 +0100 Subject: [PATCH] sna/gen8: Check offset alignment before using a userptr for RENDER Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79053 Signed-off-by: Chris Wilson --- src/sna/gen8_render.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/sna/gen8_render.c b/src/sna/gen8_render.c index c66f7cc..437c49b 100644 --- a/src/sna/gen8_render.c +++ b/src/sna/gen8_render.c @@ -2934,6 +2934,31 @@ gen8_render_copy_done(struct sna *sna, const struct sna_copy_op *op) gen8_vertex_flush(sna); } +static bool unaligned(struct kgem_bo *bo, int bpp) +{ + int x, y; + + if (bo->proxy == NULL) + return false; + + /* Assume that all tiled proxies are constructed correctly. */ + if (bo->tiling) + return true; + + /* This may be a random userptr map, check that it meets the + * render alignment of SURFACE_VALIGN_4 | SURFACE_HALIGN_4; + */ + y = bo->delta / bo->pitch; + if (y & 3) + return false; + + x = 8 * (bo->delta - y * bo->pitch); + if (x & (4*bpp - 1)) + return false; + + return true; +} + static bool gen8_render_copy(struct sna *sna, uint8_t alu, PixmapPtr src, struct kgem_bo *src_bo, @@ -2954,6 +2979,8 @@ gen8_render_copy(struct sna *sna, uint8_t alu, return true; if (!(alu == GXcopy || alu == GXclear) || src_bo == dst_bo || + unaligned(src_bo, src->drawable.bitsPerPixel) || + unaligned(dst_bo, dst->drawable.bitsPerPixel) || too_large(src->drawable.width, src->drawable.height) || too_large(dst->drawable.width, dst->drawable.height)) { fallback: -- 2.0.0