From 4b7bbb2a23b03bac63f864c33f47fab88dedbf67 Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Fri, 7 Dec 2012 16:43:32 +0000 Subject: sna: Only flush before adding fresh surfaces to the batch Previously, before every operation we would look to see if the GPU was idle and we were running under a DRI compositor. If the GPU was idle, we would flush the batch in the hope that we reduce the cost of the context switch and copy from the compositor (by completing the work earlier). However, we would complete the work far too earlier and as a result would need to flush the batch before every single operation resulting in extra overhead and reduced performance. For example, the gtkperf circles benchmark under gnome-shell/compiz would be 2x slower on Ivybridge. Reported-by: Michael Larabel Signed-off-by: Chris Wilson --- src/sna/kgem.c | 18 +++++++++--------- src/sna/kgem.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/sna/kgem.c b/src/sna/kgem.c index 2138f1a2..200c7555 100644 --- a/src/sna/kgem.c +++ b/src/sna/kgem.c @@ -3716,9 +3716,6 @@ bool kgem_check_bo(struct kgem *kgem, ...) int num_exec = 0; int num_pages = 0; - if (kgem_flush(kgem)) - return false; - va_start(ap, kgem); while ((bo = va_arg(ap, struct kgem_bo *))) { if (bo->exec) @@ -3740,6 +3737,9 @@ bool kgem_check_bo(struct kgem *kgem, ...) if (!num_pages) return true; + if (kgem_flush(kgem)) + return false; + if (kgem->aperture > kgem->aperture_low && kgem_is_idle(kgem)) { DBG(("%s: current aperture usage (%d) is greater than low water mark (%d)\n", __FUNCTION__, kgem->aperture, kgem->aperture_low)); @@ -3765,9 +3765,6 @@ bool kgem_check_bo_fenced(struct kgem *kgem, struct kgem_bo *bo) { uint32_t size; - if (kgem_flush(kgem)) - return false; - while (bo->proxy) bo = bo->proxy; if (bo->exec) { @@ -3786,6 +3783,9 @@ bool kgem_check_bo_fenced(struct kgem *kgem, struct kgem_bo *bo) return true; } + if (kgem_flush(kgem)) + return false; + if (kgem->nexec >= KGEM_EXEC_SIZE(kgem) - 1) return false; @@ -3820,9 +3820,6 @@ bool kgem_check_many_bo_fenced(struct kgem *kgem, ...) int num_pages = 0; int fenced_size = 0; - if (kgem_flush(kgem)) - return false; - va_start(ap, kgem); while ((bo = va_arg(ap, struct kgem_bo *))) { while (bo->proxy) @@ -3860,6 +3857,9 @@ bool kgem_check_many_bo_fenced(struct kgem *kgem, ...) } if (num_pages) { + if (kgem_flush(kgem)) + return false; + if (kgem->aperture > kgem->aperture_low && kgem_is_idle(kgem)) return false; diff --git a/src/sna/kgem.h b/src/sna/kgem.h index 2d04b53c..8a3a4fa2 100644 --- a/src/sna/kgem.h +++ b/src/sna/kgem.h @@ -294,7 +294,7 @@ static inline void kgem_submit(struct kgem *kgem) static inline bool kgem_flush(struct kgem *kgem) { - return kgem->flush && kgem_is_idle(kgem); + return kgem->flush && list_is_empty(&kgem->requests[kgem->ring]); } static inline void kgem_bo_submit(struct kgem *kgem, struct kgem_bo *bo) -- cgit v1.2.3