From deaa1cac269be03f4ec44092f70349ff466d59de Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Tue, 28 Aug 2012 22:23:22 +0100 Subject: [PATCH] sna: Align active upload buffers to the next page for reuse If we write to the same page as it already active on the GPU then despite the invalidation performed at the beginning of each batch, we do not seem to correctly sample the new data. References: https://bugs.freedesktop.org/show_bug.cgi?id=51422 References: https://bugs.freedesktop.org/show_bug.cgi?id=52299 Signed-off-by: Chris Wilson --- src/sna/kgem.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index e51bbc0d..ed5e3428 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -1910,13 +1910,18 @@ static void kgem_finish_buffers(struct kgem *kgem) } if (bo->mmapped) { + int used; + assert(!bo->need_io); + + used = ALIGN(bo->used + PAGE_SIZE-1, PAGE_SIZE); if (!DBG_NO_UPLOAD_ACTIVE && - bo->used + PAGE_SIZE <= bytes(&bo->base) && + used + PAGE_SIZE <= bytes(&bo->base) && (kgem->has_llc || !IS_CPU_MAP(bo->base.map))) { DBG(("%s: retaining upload buffer (%d/%d)\n", __FUNCTION__, bo->used, bytes(&bo->base))); assert(!bo->base.snoop); + bo->used = used; list_move(&bo->base.list, &kgem->active_buffers); continue;