xf86-video-intel: 3 commits - src/sna/kgem.c src/sna/kgem.h src/sna/sna_display.c src/sna/sna_dri2.c src/sna/sna_glyphs.c src/sna/sna_render_inline.h src/sna/sna_trapezoids.c tools/virtual.c

Chris Wilson ickle at kemper.freedesktop.org
Fri Jun 13 10:38:08 PDT 2014


 src/sna/kgem.c              |    2 --
 src/sna/kgem.h              |   13 +++++++++++--
 src/sna/sna_display.c       |   13 +++++++++++++
 src/sna/sna_dri2.c          |    2 +-
 src/sna/sna_glyphs.c        |    6 ++----
 src/sna/sna_render_inline.h |   23 +++++++++++++++++++++++
 src/sna/sna_trapezoids.c    |    8 +++-----
 tools/virtual.c             |   19 +++++++++++++++++++
 8 files changed, 72 insertions(+), 14 deletions(-)

New commits:
commit c8074b6bcfa8c208433574721135faa4d919d32a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Jun 13 18:37:15 2014 +0100

    intel-virtual-output: Check for an error creating the DRI3 fd
    
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=79994
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/tools/virtual.c b/tools/virtual.c
index a5dccb4..4b1c968 100644
--- a/tools/virtual.c
+++ b/tools/virtual.c
@@ -1047,6 +1047,8 @@ static void output_init_xfer(struct clone *clone, struct output *output)
 	if (output->gc == None) {
 		XGCValues gcv;
 
+		DBG(("%s-%s: creating gc\n", DisplayString(output->dpy), output->name));
+
 		gcv.graphics_exposures = False;
 		gcv.subwindow_mode = IncludeInferiors;
 
@@ -1121,7 +1123,17 @@ static int clone_init_xfer(struct clone *clone)
 
 		_x_error_occurred = 0;
 
+		DBG(("%s-%s create xfer, trying DRI3\n",
+		     DisplayString(clone->dst.dpy), clone->dst.name));
+
 		fd = dri3_create_fd(clone->dst.dpy, clone->dst.window, &stride);
+		if (fd < 0)
+			goto disable_dri3;
+
+		DBG(("%s-%s create xfer, DRI3 fd=%d, stride=%d\n",
+		     DisplayString(clone->dst.dpy), clone->dst.name,
+		     fd, stride));
+
 		src = dri3_create_pixmap(clone->src.dpy, clone->src.window,
 					 width, height, clone->depth,
 					 fd, bpp_for_depth(clone->depth),
@@ -1135,8 +1147,12 @@ static int clone_init_xfer(struct clone *clone)
 		} else {
 			XFreePixmap(clone->src.dpy, src);
 			close(fd);
+disable_dri3:
 			dri3_fence_free(clone->src.dpy, &clone->dri3);
 			clone->dri3.xid = 0;
+
+			DBG(("%s-%s create xfer, DRI3 failed\n",
+			     DisplayString(clone->dst.dpy), clone->dst.name));
 		}
 	}
 
@@ -1144,6 +1160,9 @@ static int clone_init_xfer(struct clone *clone)
 	height = mode_height(&clone->src.mode, clone->src.rotation);
 
 	if (!clone->dri3.xid) {
+		DBG(("%s-%s create xfer, trying SHM\n",
+		     DisplayString(clone->dst.dpy), clone->dst.name));
+
 		clone->shm.shmid = shmget(IPC_PRIVATE,
 					  height * stride_for_depth(width, clone->depth),
 					  IPC_CREAT | 0666);
commit 0a0b9dc3538ef731463fb321852b8802cd04e457
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Jun 13 16:14:43 2014 +0100

    sna: Refine decision whether to use the GPU or render inplace
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/sna_glyphs.c b/src/sna/sna_glyphs.c
index 5d8dd78..e8d92b8 100644
--- a/src/sna/sna_glyphs.c
+++ b/src/sna/sna_glyphs.c
@@ -1948,8 +1948,7 @@ sna_glyphs(CARD8 op,
 		goto fallback;
 	}
 
-	if ((too_small(priv) || DAMAGE_IS_ALL(priv->cpu_damage)) &&
-	    !picture_is_gpu(sna, src, 0)) {
+	if (!is_gpu_dst(priv) && !picture_is_gpu(sna, src, 0)) {
 		DBG(("%s: fallback -- too small (%dx%d)\n",
 		     __FUNCTION__, dst->pDrawable->width, dst->pDrawable->height));
 		goto fallback;
@@ -2278,8 +2277,7 @@ sna_glyphs__shared(CARD8 op,
 		goto fallback;
 	}
 
-	if ((too_small(priv) || DAMAGE_IS_ALL(priv->cpu_damage)) &&
-	    !picture_is_gpu(sna, src, 0)) {
+	if (!is_gpu_dst(priv) && !picture_is_gpu(sna, src, 0)) {
 		DBG(("%s: fallback -- too small (%dx%d)\n",
 		     __FUNCTION__, dst->pDrawable->width, dst->pDrawable->height));
 		goto fallback;
diff --git a/src/sna/sna_render_inline.h b/src/sna/sna_render_inline.h
index e292949..50a19c8 100644
--- a/src/sna/sna_render_inline.h
+++ b/src/sna/sna_render_inline.h
@@ -92,6 +92,9 @@ is_gpu(struct sna *sna, DrawablePtr drawable, unsigned prefer)
 	if (priv->cpu_bo && kgem_bo_is_busy(priv->cpu_bo))
 		return true;
 
+	if (DAMAGE_IS_ALL(priv->cpu_damage))
+		return false;
+
 	return priv->gpu_bo && kgem_bo_is_busy(priv->gpu_bo);
 }
 
@@ -110,6 +113,26 @@ too_small(struct sna_pixmap *priv)
 }
 
 static inline bool
+is_gpu_dst(struct sna_pixmap *priv)
+{
+	assert(priv);
+
+	if (too_small(priv))
+		return false;
+
+	if (priv->gpu_bo && kgem_bo_is_busy(priv->gpu_bo))
+		return true;
+
+	if (priv->cpu_bo && kgem_bo_is_busy(priv->cpu_bo))
+		return true;
+
+	if (DAMAGE_IS_ALL(priv->cpu_damage))
+		return false;
+
+	return priv->gpu_damage == NULL && priv->cpu;
+}
+
+static inline bool
 unattached(DrawablePtr drawable)
 {
 	struct sna_pixmap *priv = sna_pixmap_from_drawable(drawable);
diff --git a/src/sna/sna_trapezoids.c b/src/sna/sna_trapezoids.c
index c11a141..789be9c 100644
--- a/src/sna/sna_trapezoids.c
+++ b/src/sna/sna_trapezoids.c
@@ -595,12 +595,10 @@ sna_composite_trapezoids(CARD8 op,
 	}
 
 	if (FORCE_FALLBACK == 0 &&
-	    (too_small(priv) || DAMAGE_IS_ALL(priv->cpu_damage)) &&
-	    !picture_is_gpu(sna, src, 0) && untransformed(src)) {
-		DBG(("%s: force fallbacks -- (too small, %dx%d? %d || all-cpu? %d) && (src-is-cpu? %d && untransformed? %d)\n",
+	    !is_gpu_dst(priv) && !picture_is_gpu(sna, src, 0) && untransformed(src)) {
+		DBG(("%s: force fallbacks -- (!gpu dst, %dx%d? %d) && (src-is-cpu? %d && untransformed? %d)\n",
 		     __FUNCTION__, dst->pDrawable->width, dst->pDrawable->height,
-		     too_small(priv), (int)DAMAGE_IS_ALL(priv->cpu_damage),
-		     !picture_is_gpu(sna, src, 0), untransformed(src)));
+		     !is_gpu_dst(priv), !picture_is_gpu(sna, src, 0), untransformed(src)));
 
 force_fallback:
 		force_fallback = true;
commit dd87aa8f85c4bafa105fd881a0cce45bda6143df
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Jun 13 15:06:13 2014 +0100

    sna: Track the pageflip bo's busyness
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/sna/kgem.c b/src/sna/kgem.c
index 7582e07..88f1b91 100644
--- a/src/sna/kgem.c
+++ b/src/sna/kgem.c
@@ -118,8 +118,6 @@ search_snoop_cache(struct kgem *kgem, unsigned int num_pages, unsigned flags);
 #define MAKE_USER_MAP(ptr) ((void*)((uintptr_t)(ptr) | 1))
 #define IS_USER_MAP(ptr) ((uintptr_t)(ptr) & 1)
 
-#define MAKE_REQUEST(rq, ring) ((struct kgem_request *)((uintptr_t)(rq) | (ring)))
-
 #define LOCAL_I915_PARAM_HAS_BLT		11
 #define LOCAL_I915_PARAM_HAS_RELAXED_FENCING	12
 #define LOCAL_I915_PARAM_HAS_RELAXED_DELTA	15
diff --git a/src/sna/kgem.h b/src/sna/kgem.h
index a52287d..8ba7a9e 100644
--- a/src/sna/kgem.h
+++ b/src/sna/kgem.h
@@ -50,6 +50,8 @@ struct kgem_bo {
 #define RQ(rq) ((struct kgem_request *)((uintptr_t)(rq) & ~3))
 #define RQ_RING(rq) ((uintptr_t)(rq) & 3)
 #define RQ_IS_BLT(rq) (RQ_RING(rq) == KGEM_BLT)
+#define MAKE_REQUEST(rq, ring) ((struct kgem_request *)((uintptr_t)(rq) | (ring)))
+
 	struct drm_i915_gem_exec_object2 *exec;
 
 	struct kgem_bo *proxy;
@@ -569,10 +571,17 @@ void kgem_bo_pair_undo(struct kgem *kgem, struct kgem_bo *a, struct kgem_bo *b);
 
 bool __kgem_busy(struct kgem *kgem, int handle);
 
-static inline void kgem_bo_mark_busy(struct kgem_bo *bo, int ring)
+static inline void kgem_bo_mark_busy(struct kgem *kgem, struct kgem_bo *bo, int ring)
 {
 	assert(bo->refcnt);
-	bo->rq = (struct kgem_request *)((uintptr_t)bo->rq | ring);
+	bo->needs_flush = true;
+	if (bo->rq) {
+		bo->rq = MAKE_REQUEST(RQ(bo->rq), ring);
+	} else {
+		bo->rq = MAKE_REQUEST(kgem, ring);
+		list_add(&bo->request, &kgem->flushing);
+		kgem->need_retire = true;
+	}
 }
 
 inline static void __kgem_bo_clear_busy(struct kgem_bo *bo)
diff --git a/src/sna/sna_display.c b/src/sna/sna_display.c
index 5e6de55..eeab349 100644
--- a/src/sna/sna_display.c
+++ b/src/sna/sna_display.c
@@ -6350,6 +6350,19 @@ fixup_flip:
 			crtc->flip_handler = shadow_flip_handler;
 			crtc->flip_bo = kgem_bo_reference(flip_bo);
 			crtc->flip_bo->active_scanout++;
+
+			{
+				struct drm_i915_gem_busy busy = { flip_bo->handle };
+				if (drmIoctl(sna->kgem.fd, DRM_IOCTL_I915_GEM_BUSY, &busy) == 0) {
+					if (busy.busy) {
+						int mode = KGEM_RENDER;
+						if (busy.busy & (1 << 17))
+							mode = KGEM_BLT;
+						kgem_bo_mark_busy(&sna->kgem, flip_bo, mode);
+					} else
+						__kgem_bo_clear_busy(flip_bo);
+				}
+			}
 		}
 
 		DBG(("%s: flipped %d outputs, shadow active? %d\n",
diff --git a/src/sna/sna_dri2.c b/src/sna/sna_dri2.c
index 21feed5..efc790f 100644
--- a/src/sna/sna_dri2.c
+++ b/src/sna/sna_dri2.c
@@ -790,7 +790,7 @@ static void sna_dri2_select_mode(struct sna *sna, struct kgem_bo *dst, struct kg
 	mode = KGEM_RENDER;
 	if (busy.busy & (1 << 17))
 		mode = KGEM_BLT;
-	kgem_bo_mark_busy(busy.handle == src->handle ? src : dst, mode);
+	kgem_bo_mark_busy(&sna->kgem, busy.handle == src->handle ? src : dst, mode);
 	_kgem_set_mode(&sna->kgem, mode);
 }
 


More information about the xorg-commit mailing list