[PATCH 2/2] glamor: Turn on glamor with a few glamor functions enabled.

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Integrate glamor acceleration into UXA framework. Add
necessary flushing at the following points:

1. Flush UXA batch buffer before call into glamor.
2. Flush GL operations after return from a glamor function.
3. The point we need to flush UXA batch buffer, we also
   need to flush GL operations, for example, in
   intel_flush_callback and couple of places in intel_display.c.

This commit only enables two glamor functions for
fill_spans and poly_fill_rects. Will continue to enable the
reset glamor functions soon.

Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 src/Makefile.am     |    6 +--
 src/intel.h         |    1 +
 src/intel_display.c |    5 ++
 src/intel_driver.c  |   17 +++++++-
 src/intel_glamor.c  |  111 ++++++++++++++++++++++++++++++++++++++++++++++-----
 src/intel_glamor.h  |    2 +-
 src/intel_uxa.c     |   22 +++++++++-
 uxa/uxa-accel.c     |   38 +++++++++++++++--
 uxa/uxa-priv.h      |    4 +-
 uxa/uxa-render.c    |   16 ++++----
 uxa/uxa-unaccel.c   |   58 +++++++++++++-------------
 uxa/uxa.c           |   18 ++++----
 uxa/uxa.h           |   13 +++++-
 13 files changed, 236 insertions(+), 75 deletions(-)

diff --git a/src/Makefile.am b/src/Makefile.am
index 1a29390..12ff6ee 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -40,10 +40,6 @@ SUBDIRS += sna
 intel_drv_la_LIBADD += sna/libsna.la
 endif
 
-if GLAMOR
-GLAMOR_SOURCE = intel_glamor.c
-endif
-
 NULL:=#
 
 intel_drv_la_SOURCES = \
@@ -74,7 +70,7 @@ intel_drv_la_SOURCES = \
 	 i965_3d.c \
 	 i965_video.c \
 	 i965_render.c \
-	 $(GLAMOR_SOURCE) \
+	 intel_glamor.c \
 	 $(NULL)
 
 if DRI
diff --git a/src/intel.h b/src/intel.h
index 3b3f87d..b24aa02 100644
--- a/src/intel.h
+++ b/src/intel.h
@@ -318,6 +318,7 @@ typedef struct intel_screen_private {
 	void (*batch_commit_notify) (struct intel_screen_private *intel);
 
 	uxa_driver_t *uxa_driver;
+	int uxa_flags;
 	Bool need_sync;
 	int accel_pixmap_offset_alignment;
 	int accel_max_x;
diff --git a/src/intel_display.c b/src/intel_display.c
index 84c7c08..f6ffa30 100644
--- a/src/intel_display.c
+++ b/src/intel_display.c
@@ -43,6 +43,8 @@
 #include "xf86drmMode.h"
 #include "X11/Xatom.h"
 
+#include "intel_glamor.h"
+
 struct intel_mode {
 	int fd;
 	uint32_t fb_id;
@@ -451,6 +453,7 @@ intel_crtc_set_mode_major(xf86CrtcPtr crtc, DisplayModePtr mode,
 	crtc->y = y;
 	crtc->rotation = rotation;
 
+	intel_glamor_flush(intel);
 	intel_batch_submit(crtc->scrn);
 
 	mode_to_kmode(crtc->scrn, &intel_crtc->kmode, mode);
@@ -1368,6 +1371,7 @@ intel_xf86crtc_resize(ScrnInfoPtr scrn, int width, int height)
 	if (scrn->virtualX == width && scrn->virtualY == height)
 		return TRUE;
 
+	intel_glamor_flush(intel);
 	intel_batch_submit(scrn);
 
 	old_width = scrn->virtualX;
@@ -1457,6 +1461,7 @@ intel_do_pageflip(intel_screen_private *intel,
 			 new_front->handle, &mode->fb_id))
 		goto error_out;
 
+	intel_glamor_flush(intel);
 	intel_batch_submit(scrn);
 
 	/*
diff --git a/src/intel_driver.c b/src/intel_driver.c
index 24696da..ddeb40f 100644
--- a/src/intel_driver.c
+++ b/src/intel_driver.c
@@ -75,6 +75,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "i915_drm.h"
 #include <xf86drmMode.h>
 
+#include "intel_glamor.h"
+
 /* *INDENT-OFF* */
 /*
  * Note: "ColorKey" is provided for compatibility with the i810 driver.
@@ -712,6 +714,13 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
 		return FALSE;
 	}
 
+	if (!intel_glamor_pre_init(scrn)) {
+		PreInitCleanup(scrn);
+		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
+			"Failed to pre init glamor display.\n");
+		return FALSE;
+	}
+
 	/* Load the dri2 module if requested. */
 	if (intel->directRenderingType != DRI_DISABLED)
 		xf86LoadSubModule(scrn, "dri2");
@@ -813,8 +822,10 @@ intel_flush_callback(CallbackListPtr *list,
 		     pointer user_data, pointer call_data)
 {
 	ScrnInfoPtr scrn = user_data;
-	if (scrn->vtSema)
+	if (scrn->vtSema) {
 		intel_batch_submit(scrn);
+		intel_glamor_flush(intel_get_screen_private(scrn));
+	}
 }
 
 #if HAVE_UDEV
@@ -1110,6 +1121,8 @@ static void I830FreeScreen(int scrnIndex, int flags)
 	ScrnInfoPtr scrn = xf86Screens[scrnIndex];
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 
+	intel_glamor_free_screen(scrnIndex, flags);
+
 	if (intel) {
 		intel_mode_fini(intel);
 		intel_close_drm_master(intel);
@@ -1189,6 +1202,8 @@ static Bool I830CloseScreen(int scrnIndex, ScreenPtr screen)
 
 	DeleteCallback(&FlushCallback, intel_flush_callback, scrn);
 
+	intel_glamor_close_screen(screen);
+
 	if (intel->uxa_driver) {
 		uxa_driver_fini(screen);
 		free(intel->uxa_driver);
diff --git a/src/intel_glamor.c b/src/intel_glamor.c
index cadfc71..a3e2c44 100644
--- a/src/intel_glamor.c
+++ b/src/intel_glamor.c
@@ -48,6 +48,9 @@ intel_glamor_create_screen_resources(ScreenPtr screen)
 	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 
+	if (!(intel->uxa_flags & UXA_USE_GLAMOR))
+		return TRUE;
+
 	if (!glamor_glyphs_init(screen))
 		return FALSE;
 	if (!glamor_egl_create_textured_screen(screen,
@@ -60,57 +63,132 @@ intel_glamor_create_screen_resources(ScreenPtr screen)
 Bool
 intel_glamor_pre_init(ScrnInfoPtr scrn)
 {
+#ifdef GLAMOR
 	intel_screen_private *intel;
 	intel = intel_get_screen_private(scrn);
+
+	/* Load glamor module */
+	if (!xf86LoadSubModule(scrn, "glamor_egl"))
+		return FALSE;
+
 	return glamor_egl_init(scrn, intel->drmSubFD);
+#else
+	return TRUE;
+#endif
 }
 
 Bool
 intel_glamor_create_textured_pixmap(PixmapPtr pixmap)
 {
 	struct intel_pixmap *priv;
+	ScrnInfoPtr scrn = xf86Screens[pixmap->drawable.pScreen->myNum];
+	intel_screen_private * intel;
+
 	priv = intel_get_pixmap_private(pixmap);
-	return glamor_egl_create_textured_pixmap(pixmap, priv->bo->handle,
-						 priv->stride);
+	intel = intel_get_screen_private(scrn);
+	if ((intel->uxa_flags & UXA_USE_GLAMOR)
+	     && glamor_egl_create_textured_pixmap(pixmap, priv->bo->handle,
+						  priv->stride)) {
+		priv->pinned = 1;
+		return TRUE;
+	}
+	return FALSE;
 }
 
 void
 intel_glamor_destroy_pixmap(PixmapPtr pixmap)
 {
-	glamor_egl_destroy_textured_pixmap(pixmap);
+	ScrnInfoPtr scrn = xf86Screens[pixmap->drawable.pScreen->myNum];
+	intel_screen_private * intel;
+
+	intel = intel_get_screen_private(scrn);
+	if (intel->uxa_flags & UXA_USE_GLAMOR)
+		glamor_egl_destroy_textured_pixmap(pixmap);
+}
+
+static void
+intel_glamor_need_flush(DrawablePtr pDrawable)
+{
+	ScrnInfoPtr scrn = xf86Screens[pDrawable->pScreen->myNum];
+	intel_screen_private * intel;
+
+	intel = intel_get_screen_private(scrn);
+	intel->needs_flush = TRUE;
 }
 
+static void
+intel_glamor_finish_access(PixmapPtr pixmap, uxa_access_t access)
+{
+	switch(access) {
+	case UXA_ACCESS_RO:
+	case UXA_ACCESS_RW:
+	case UXA_GLAMOR_ACCESS_RO:
+		break;
+	case UXA_GLAMOR_ACCESS_RW:
+		intel_glamor_need_flush(&pixmap->drawable);
+		glamor_block_handler(pixmap->drawable.pScreen);
+		break;
+	default:
+		ErrorF("Invalid access mode %d\n", access);
+	}
+
+	return;
+}
+
+
 Bool
 intel_glamor_init(ScreenPtr screen)
 {
+#ifdef GLAMOR
 	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	intel_screen_private * intel;
 
 	if (!glamor_init(screen, GLAMOR_INVERTED_Y_AXIS)) {
 		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
 			   "Failed to initialize glamor\n");
-		return FALSE;
+		goto fail;
 	}
 
 	if (!glamor_egl_init_textured_pixmap(screen)) {
 		xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-			   "Failed to initialize glamor\n");
-		return FALSE;
+			   "Failed to initialize textured pixmap.\n");
+		goto fail;
 	}
 
+	intel = intel_get_screen_private(scrn);
+	intel->uxa_driver->flags |= UXA_USE_GLAMOR;
+	intel->uxa_flags = intel->uxa_driver->flags;
+
+	intel->uxa_driver->finish_access = intel_glamor_finish_access;
+
+	xf86DrvMsg(scrn->scrnIndex, X_INFO,
+		   "Use GLAMOR acceleration.\n");
+	return TRUE;
+
+  fail:
+	xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+		   "Use standard UXA acceleration.");
+	return FALSE;
+#else
 	return TRUE;
+#endif
 }
 
 void
-intel_glamor_block_handler(intel_screen_private * intel)
+intel_glamor_flush(intel_screen_private * intel)
 {
-	ScreenPtr screen = screenInfo.screens[intel->scrn->scrnIndex];
-	glamor_block_handler(screen);
+	ScreenPtr screen;
+
+	screen = screenInfo.screens[intel->scrn->scrnIndex];
+	if (intel->uxa_flags & UXA_USE_GLAMOR)
+		glamor_block_handler(screen);
 }
 
 Bool
 intel_glamor_create_screen_image(ScreenPtr screen, int handle, int stride)
 {
 	PixmapPtr pixmap;
+
 	if (!glamor_egl_create_textured_screen(screen, handle, stride))
 		return FALSE;
 	pixmap = screen->GetScreenPixmap(screen);
@@ -120,11 +198,22 @@ intel_glamor_create_screen_image(ScreenPtr screen, int handle, int stride)
 Bool
 intel_glamor_close_screen(ScreenPtr screen)
 {
-	return glamor_egl_close_screen(screen);
+	ScrnInfoPtr scrn = xf86Screens[screen->myNum];
+	intel_screen_private * intel;
+
+	intel = intel_get_screen_private(scrn);
+	if (intel && (intel->uxa_flags & UXA_USE_GLAMOR))
+		return glamor_egl_close_screen(screen);
+	return TRUE;
 }
 
 void
 intel_glamor_free_screen(int scrnIndex, int flags)
 {
-	glamor_egl_free_screen(scrnIndex, GLAMOR_EGL_EXTERNAL_BUFFER);
+	ScrnInfoPtr scrn = xf86Screens[scrnIndex];
+	intel_screen_private * intel;
+
+	intel = intel_get_screen_private(scrn);
+	if (intel && (intel->uxa_flags & UXA_USE_GLAMOR))
+		glamor_egl_free_screen(scrnIndex, GLAMOR_EGL_EXTERNAL_BUFFER);
 }
diff --git a/src/intel_glamor.h b/src/intel_glamor.h
index d7c2c86..3c06be0 100644
--- a/src/intel_glamor.h
+++ b/src/intel_glamor.h
@@ -38,7 +38,7 @@ Bool intel_glamor_close_screen(ScreenPtr screen);
 
 void intel_glamor_free_screen(int scrnIndex, int flags);
 
-void intel_glamor_block_handler(intel_screen_private * intel);
+void intel_glamor_flush(intel_screen_private * intel);
 
 Bool intel_glamor_create_textured_pixmap(PixmapPtr pixmap);
 
diff --git a/src/intel_uxa.c b/src/intel_uxa.c
index 8c6f754..8ec4133 100644
--- a/src/intel_uxa.c
+++ b/src/intel_uxa.c
@@ -40,6 +40,8 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <string.h>
 #include <errno.h>
 
+#include "intel_glamor.h"
+
 static const int I830CopyROP[16] = {
 	ROP_0,			/* GXclear */
 	ROP_DSa,		/* GXand */
@@ -703,9 +705,15 @@ static Bool intel_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)
 	int ret;
 
 	if (!list_is_empty(&priv->batch) &&
-	    (access == UXA_ACCESS_RW || priv->batch_write))
+	    ((access == UXA_ACCESS_RW || access == UXA_GLAMOR_ACCESS_RW)
+	     || priv->batch_write))
 		intel_batch_submit(scrn);
 
+	if (access == UXA_GLAMOR_ACCESS_RW || access == UXA_GLAMOR_ACCESS_RO)
+		return TRUE;
+
+	intel_glamor_flush(intel);
+
 	if (priv->tiling || bo->size <= intel->max_gtt_map_size)
 		ret = drm_intel_gem_bo_map_gtt(bo);
 	else
@@ -964,6 +972,7 @@ void intel_uxa_block_handler(intel_screen_private *intel)
 	 * and beyond rendering results may not hit the
 	 * framebuffer until significantly later.
 	 */
+	intel_glamor_flush(intel);
 	intel_flush_rendering(intel);
 }
 
@@ -1095,6 +1104,8 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 		list_init(&priv->batch);
 		list_init(&priv->flush);
 		intel_set_pixmap_private(pixmap, priv);
+
+		intel_glamor_create_textured_pixmap(pixmap);
 	}
 
 	return pixmap;
@@ -1102,8 +1113,10 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 
 static Bool intel_uxa_destroy_pixmap(PixmapPtr pixmap)
 {
-	if (pixmap->refcnt == 1)
+	if (pixmap->refcnt == 1) {
+		intel_glamor_destroy_pixmap(pixmap);
 		intel_set_pixmap_bo(pixmap, NULL);
+	}
 	fbDestroyPixmap(pixmap);
 	return TRUE;
 }
@@ -1134,6 +1147,9 @@ Bool intel_uxa_create_screen_resources(ScreenPtr screen)
 		scrn->displayWidth = intel->front_pitch / intel->cpp;
 	}
 
+	if (!intel_glamor_create_screen_resources(screen))
+		return FALSE;
+
 	return TRUE;
 }
 
@@ -1296,5 +1312,7 @@ Bool intel_uxa_init(ScreenPtr screen)
 	uxa_set_fallback_debug(screen, intel->fallback_debug);
 	uxa_set_force_fallback(screen, intel->force_fallback);
 
+	intel_glamor_init(screen);
+
 	return TRUE;
 }
diff --git a/uxa/uxa-accel.c b/uxa/uxa-accel.c
index 516834f..c56fd81 100644
--- a/uxa/uxa-accel.c
+++ b/uxa/uxa-accel.c
@@ -27,7 +27,6 @@
  *    Michel D?nzer <michel at tungstengraphics.com>
  *
  */
-
 #ifdef HAVE_DIX_CONFIG_H
 #include <dix-config.h>
 #endif
@@ -37,6 +36,13 @@
 #include "uxa.h"
 #include "mipict.h"
 
+#ifdef GLAMOR
+#include "glamor.h"
+#else
+#define glamor_fill_spans_nf(...)  FALSE
+#define glamor_poly_fill_rect_nf(...) FALSE
+#endif
+
 static void
 uxa_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int n,
 	       DDXPointPtr ppt, int *pwidth, int fSorted)
@@ -50,6 +56,17 @@ uxa_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int n,
 	int x1, x2, y;
 	int off_x, off_y;
 
+	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
+		uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
+		if (glamor_fill_spans_nf(pDrawable,
+					 pGC, n, ppt, pwidth, fSorted)) {
+			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
+			return;
+		}
+		uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RO);
+		goto fallback;
+	}
+
 	if (uxa_screen->swappedOut || uxa_screen->force_fallback)
 		goto fallback;
 
@@ -187,7 +204,7 @@ uxa_do_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth, int x, int y,
 				  (x1 + dstXoff) * dstBpp, (x2 - x1) * dstBpp,
 				  y2 - y1, GXcopy, FB_ALLONES, dstBpp);
 
-			uxa_finish_access(pDrawable);
+			uxa_finish_access(pDrawable, UXA_ACCESS_RW);
 		}
 	}
 
@@ -481,9 +498,9 @@ fallback:
 				   dx, dy, reverse, upsidedown, bitplane,
 				   closure);
 			if (pSrcDrawable != pDstDrawable)
-				uxa_finish_access(pSrcDrawable);
+				uxa_finish_access(pSrcDrawable, UXA_ACCESS_RO);
 		}
-		uxa_finish_access(pDstDrawable);
+		uxa_finish_access(pDstDrawable, UXA_ACCESS_RW);
 	}
 }
 
@@ -673,6 +690,17 @@ uxa_poly_fill_rect(DrawablePtr pDrawable,
 	int n;
 	RegionPtr pReg = RECTS_TO_REGION(pScreen, nrect, prect, CT_UNSORTED);
 
+	if (uxa_screen->info->flags & UXA_USE_GLAMOR) {
+		uxa_prepare_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
+		if (glamor_poly_fill_rect_nf(pDrawable,
+					     pGC, nrect, prect)) {
+			uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RW);
+			return;
+		}
+		uxa_finish_access(pDrawable, UXA_GLAMOR_ACCESS_RO);
+		goto fallback;
+	}
+
 	/* Compute intersection of rects and clip region */
 	REGION_TRANSLATE(pScreen, pReg, pDrawable->x, pDrawable->y);
 	REGION_INTERSECT(pScreen, pReg, pClip, pReg);
@@ -1013,7 +1041,7 @@ fallback:
 
 	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RO)) {
 		fbGetImage(pDrawable, x, y, w, h, format, planeMask, d);
-		uxa_finish_access(pDrawable);
+		uxa_finish_access(pDrawable, UXA_ACCESS_RO);
 	}
 
 	return;
diff --git a/uxa/uxa-priv.h b/uxa/uxa-priv.h
index 6b9a9c1..a455f25 100644
--- a/uxa/uxa-priv.h
+++ b/uxa/uxa-priv.h
@@ -325,10 +325,10 @@ uxa_check_composite(CARD8 op,
 
 /* uxa.c */
 Bool uxa_prepare_access(DrawablePtr pDrawable, uxa_access_t access);
-void uxa_finish_access(DrawablePtr pDrawable);
+void uxa_finish_access(DrawablePtr pDrawable, uxa_access_t access);
 
 Bool uxa_picture_prepare_access(PicturePtr picture, int mode);
-void uxa_picture_finish_access(PicturePtr picture);
+void uxa_picture_finish_access(PicturePtr picture, int mode);
 
 void
 uxa_get_drawable_deltas(DrawablePtr pDrawable, PixmapPtr pPixmap,
diff --git a/uxa/uxa-render.c b/uxa/uxa-render.c
index 34257c6..51c12f1 100644
--- a/uxa/uxa-render.c
+++ b/uxa/uxa-render.c
@@ -571,7 +571,7 @@ uxa_picture_from_pixman_image(ScreenPtr screen,
 		if (uxa_picture_prepare_access(picture, UXA_ACCESS_RW)) {
 			fbComposite(PictOpSrc, src, NULL, picture,
 				    0, 0, 0, 0, 0, 0, width, height);
-			uxa_picture_finish_access(picture);
+			uxa_picture_finish_access(picture, UXA_ACCESS_RW);
 		}
 
 		FreePicture(src, 0);
@@ -599,7 +599,7 @@ uxa_create_solid(ScreenPtr screen, uint32_t color)
 		return 0;
 	}
 	*((uint32_t *)pixmap->devPrivate.ptr) = color;
-	uxa_finish_access((DrawablePtr)pixmap);
+	uxa_finish_access((DrawablePtr)pixmap, UXA_ACCESS_RW);
 
 	picture = CreatePicture(0, &pixmap->drawable,
 				PictureMatchFormat(screen, 32, PICT_a8r8g8b8),
@@ -702,7 +702,7 @@ uxa_acquire_pattern(ScreenPtr pScreen,
 	if (uxa_picture_prepare_access(pDst, UXA_ACCESS_RW)) {
 		fbComposite(PictOpSrc, pSrc, NULL, pDst,
 			    x, y, 0, 0, 0, 0, width, height);
-		uxa_picture_finish_access(pDst);
+		uxa_picture_finish_access(pDst, UXA_ACCESS_RW);
 		return pDst;
 	} else {
 		FreePicture(pDst, 0);
@@ -761,9 +761,9 @@ uxa_render_picture(ScreenPtr screen,
 			ret = 1;
 			fbComposite(PictOpSrc, src, NULL, picture,
 				    x, y, 0, 0, 0, 0, width, height);
-			uxa_picture_finish_access(src);
+			uxa_picture_finish_access(src, UXA_ACCESS_RO);
 		}
-		uxa_picture_finish_access(picture);
+		uxa_picture_finish_access(picture, UXA_ACCESS_RW);
 	}
 
 	if (!ret) {
@@ -1902,7 +1902,7 @@ uxa_trapezoids(CARD8 op, PicturePtr src, PicturePtr dst,
 
 			for (; ntrap; ntrap--, traps++)
 				(*ps->RasterizeTrapezoid) (dst, traps, 0, 0);
-			uxa_finish_access(pDraw);
+			uxa_finish_access(pDraw, UXA_ACCESS_RW);
 		}
 	} else if (maskFormat) {
 		PixmapPtr scratch = NULL;
@@ -2013,7 +2013,7 @@ uxa_triangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
 		DrawablePtr pDraw = pDst->pDrawable;
 		if (uxa_prepare_access(pDraw, UXA_ACCESS_RW)) {
 			(*ps->AddTriangles) (pDst, 0, 0, ntri, tris);
-			uxa_finish_access(pDraw);
+			uxa_finish_access(pDraw, UXA_ACCESS_RW);
 		}
 	} else if (maskFormat) {
 		PicturePtr pPicture;
@@ -2049,7 +2049,7 @@ uxa_triangles(CARD8 op, PicturePtr pSrc, PicturePtr pDst,
 		if (uxa_prepare_access(pPicture->pDrawable, UXA_ACCESS_RW)) {
 			(*ps->AddTriangles) (pPicture, -bounds.x1, -bounds.y1,
 					     ntri, tris);
-			uxa_finish_access(pPicture->pDrawable);
+			uxa_finish_access(pPicture->pDrawable, UXA_ACCESS_RW);
 		}
 
 		xRel = bounds.x1 + xSrc - xDst;
diff --git a/uxa/uxa-unaccel.c b/uxa/uxa-unaccel.c
index 1d4b2c0..f431049 100644
--- a/uxa/uxa-unaccel.c
+++ b/uxa/uxa-unaccel.c
@@ -50,7 +50,7 @@ Bool uxa_prepare_access_gc(GCPtr pGC)
 		if (!uxa_prepare_access
 		    (&pGC->tile.pixmap->drawable, UXA_ACCESS_RO)) {
 			if (pGC->stipple)
-				uxa_finish_access(&pGC->stipple->drawable);
+				uxa_finish_access(&pGC->stipple->drawable, UXA_ACCESS_RO);
 			return FALSE;
 		}
 	return TRUE;
@@ -62,9 +62,9 @@ Bool uxa_prepare_access_gc(GCPtr pGC)
 void uxa_finish_access_gc(GCPtr pGC)
 {
 	if (pGC->fillStyle == FillTiled)
-		uxa_finish_access(&pGC->tile.pixmap->drawable);
+		uxa_finish_access(&pGC->tile.pixmap->drawable, UXA_ACCESS_RO);
 	if (pGC->stipple)
-		uxa_finish_access(&pGC->stipple->drawable);
+		uxa_finish_access(&pGC->stipple->drawable, UXA_ACCESS_RO);
 }
 
 Bool uxa_picture_prepare_access(PicturePtr picture, int mode)
@@ -77,21 +77,21 @@ Bool uxa_picture_prepare_access(PicturePtr picture, int mode)
 
 	if (picture->alphaMap &&
 	    !uxa_prepare_access(picture->alphaMap->pDrawable, mode)) {
-		uxa_finish_access(picture->pDrawable);
+		uxa_finish_access(picture->pDrawable, mode);
 		return FALSE;
 	}
 
 	return TRUE;
 }
 
-void uxa_picture_finish_access(PicturePtr picture)
+void uxa_picture_finish_access(PicturePtr picture, int mode)
 {
 	if (picture->pDrawable == NULL)
 		return;
 
-	uxa_finish_access(picture->pDrawable);
+	uxa_finish_access(picture->pDrawable, mode);
 	if (picture->alphaMap)
-		uxa_finish_access(picture->alphaMap->pDrawable);
+		uxa_finish_access(picture->alphaMap->pDrawable, mode);
 }
 
 
@@ -114,7 +114,7 @@ uxa_check_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int nspans,
 				    fSorted);
 			uxa_finish_access_gc(pGC);
 		}
-		uxa_finish_access(pDrawable);
+		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
 	}
 }
 
@@ -128,7 +128,7 @@ uxa_check_set_spans(DrawablePtr pDrawable, GCPtr pGC, char *psrc,
 		      uxa_drawable_location(pDrawable)));
 	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
 		fbSetSpans(pDrawable, pGC, psrc, ppt, pwidth, nspans, fSorted);
-		uxa_finish_access(pDrawable);
+		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
 	}
 }
 
@@ -144,7 +144,7 @@ uxa_check_put_image(DrawablePtr pDrawable, GCPtr pGC, int depth,
 	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
 		fbPutImage(pDrawable, pGC, depth, x, y, w, h, leftPad, format,
 			   bits);
-		uxa_finish_access(pDrawable);
+		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
 	}
 }
 
@@ -163,9 +163,9 @@ uxa_check_copy_area(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
 			ret =
 			    fbCopyArea(pSrc, pDst, pGC, srcx, srcy, w, h, dstx,
 				       dsty);
-			uxa_finish_access(pSrc);
+			uxa_finish_access(pSrc, UXA_ACCESS_RO);
 		}
-		uxa_finish_access(pDst);
+		uxa_finish_access(pDst, UXA_ACCESS_RW);
 	}
 	return ret;
 }
@@ -186,9 +186,9 @@ uxa_check_copy_plane(DrawablePtr pSrc, DrawablePtr pDst, GCPtr pGC,
 			ret =
 			    fbCopyPlane(pSrc, pDst, pGC, srcx, srcy, w, h, dstx,
 					dsty, bitPlane);
-			uxa_finish_access(pSrc);
+			uxa_finish_access(pSrc, UXA_ACCESS_RO);
 		}
-		uxa_finish_access(pDst);
+		uxa_finish_access(pDst, UXA_ACCESS_RW);
 	}
 	return ret;
 }
@@ -203,7 +203,7 @@ uxa_check_poly_point(DrawablePtr pDrawable, GCPtr pGC, int mode, int npt,
 		      uxa_drawable_location(pDrawable)));
 	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RW)) {
 		fbPolyPoint(pDrawable, pGC, mode, npt, pptInit);
-		uxa_finish_access(pDrawable);
+		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
 	}
 }
 
@@ -223,7 +223,7 @@ uxa_check_poly_lines(DrawablePtr pDrawable, GCPtr pGC,
 				fbPolyLine(pDrawable, pGC, mode, npt, ppt);
 				uxa_finish_access_gc(pGC);
 			}
-			uxa_finish_access(pDrawable);
+			uxa_finish_access(pDrawable, UXA_ACCESS_RW);
 		}
 		return;
 	}
@@ -247,7 +247,7 @@ uxa_check_poly_segment(DrawablePtr pDrawable, GCPtr pGC,
 					      pSegInit);
 				uxa_finish_access_gc(pGC);
 			}
-			uxa_finish_access(pDrawable);
+			uxa_finish_access(pDrawable, UXA_ACCESS_RW);
 		}
 		return;
 	}
@@ -274,7 +274,7 @@ uxa_check_poly_arc(DrawablePtr pDrawable, GCPtr pGC, int narcs, xArc * pArcs)
 				fbPolyArc(pDrawable, pGC, narcs, pArcs);
 				uxa_finish_access_gc(pGC);
 			}
-			uxa_finish_access(pDrawable);
+			uxa_finish_access(pDrawable, UXA_ACCESS_RW);
 		}
 		return;
 	}
@@ -296,7 +296,7 @@ uxa_check_poly_fill_rect(DrawablePtr pDrawable, GCPtr pGC,
 			fbPolyFillRect(pDrawable, pGC, nrect, prect);
 			uxa_finish_access_gc(pGC);
 		}
-		uxa_finish_access(pDrawable);
+		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
 	}
 }
 
@@ -315,7 +315,7 @@ uxa_check_image_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
 					pglyphBase);
 			uxa_finish_access_gc(pGC);
 		}
-		uxa_finish_access(pDrawable);
+		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
 	}
 }
 
@@ -335,7 +335,7 @@ uxa_check_poly_glyph_blt(DrawablePtr pDrawable, GCPtr pGC,
 				       pglyphBase);
 			uxa_finish_access_gc(pGC);
 		}
-		uxa_finish_access(pDrawable);
+		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
 	}
 }
 
@@ -355,9 +355,9 @@ uxa_check_push_pixels(GCPtr pGC, PixmapPtr pBitmap,
 					     y);
 				uxa_finish_access_gc(pGC);
 			}
-			uxa_finish_access(&pBitmap->drawable);
+			uxa_finish_access(&pBitmap->drawable, UXA_ACCESS_RO);
 		}
-		uxa_finish_access(pDrawable);
+		uxa_finish_access(pDrawable, UXA_ACCESS_RW);
 	}
 }
 
@@ -372,7 +372,7 @@ uxa_check_get_spans(DrawablePtr pDrawable,
 		      uxa_drawable_location(pDrawable)));
 	if (uxa_prepare_access(pDrawable, UXA_ACCESS_RO)) {
 		fbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pdstStart);
-		uxa_finish_access(pDrawable);
+		uxa_finish_access(pDrawable, UXA_ACCESS_RO);
 	}
 }
 
@@ -399,11 +399,11 @@ uxa_check_composite(CARD8 op,
 					    xDst, yDst,
 					    width, height);
 				if (pMask)
-					uxa_picture_finish_access(pMask);
+					uxa_picture_finish_access(pMask, UXA_ACCESS_RO);
 			}
-			uxa_picture_finish_access(pSrc);
+			uxa_picture_finish_access(pSrc, UXA_ACCESS_RO);
 		}
-		uxa_picture_finish_access(pDst);
+		uxa_picture_finish_access(pDst, UXA_ACCESS_RW);
 	}
 }
 
@@ -417,7 +417,7 @@ uxa_check_add_traps(PicturePtr pPicture,
 		      uxa_drawable_location(pPicture->pDrawable)));
 	if (uxa_picture_prepare_access(pPicture, UXA_ACCESS_RW)) {
 		fbAddTraps(pPicture, x_off, y_off, ntrap, traps);
-		uxa_picture_finish_access(pPicture);
+		uxa_picture_finish_access(pPicture, UXA_ACCESS_RW);
 	}
 }
 
@@ -448,7 +448,7 @@ CARD32 uxa_get_pixmap_first_pixel(PixmapPtr pPixmap)
 		pixel = *(CARD8 *) fb;
 		break;
 	}
-	uxa_finish_access(&pPixmap->drawable);
+	uxa_finish_access(&pPixmap->drawable, UXA_ACCESS_RO);
 
 	return pixel;
 }
diff --git a/uxa/uxa.c b/uxa/uxa.c
index 856a0ce..5a3c0be 100644
--- a/uxa/uxa.c
+++ b/uxa/uxa.c
@@ -160,7 +160,7 @@ Bool uxa_prepare_access(DrawablePtr pDrawable, uxa_access_t access)
  *
  * It deals with calling the driver's finish_access() only if necessary.
  */
-void uxa_finish_access(DrawablePtr pDrawable)
+void uxa_finish_access(DrawablePtr pDrawable, uxa_access_t access)
 {
 	ScreenPtr pScreen = pDrawable->pScreen;
 	uxa_screen_t *uxa_screen = uxa_get_screen(pScreen);
@@ -173,7 +173,7 @@ void uxa_finish_access(DrawablePtr pDrawable)
 	if (!uxa_pixmap_is_offscreen(pPixmap))
 		return;
 
-	(*uxa_screen->info->finish_access) (pPixmap);
+	(*uxa_screen->info->finish_access) (pPixmap, access);
 }
 
 /**
@@ -217,7 +217,7 @@ uxa_validate_gc(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
 					    fb24_32ReformatTile(pOldTile,
 								pDrawable->
 								bitsPerPixel);
-					uxa_finish_access(&pOldTile->drawable);
+					uxa_finish_access(&pOldTile->drawable, UXA_ACCESS_RO);
 				}
 			}
 			if (pNewTile) {
@@ -235,7 +235,7 @@ uxa_validate_gc(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
 			if (uxa_prepare_access
 			    (&pGC->tile.pixmap->drawable, UXA_ACCESS_RW)) {
 				fbPadPixmap(pGC->tile.pixmap);
-				uxa_finish_access(&pGC->tile.pixmap->drawable);
+				uxa_finish_access(&pGC->tile.pixmap->drawable, UXA_ACCESS_RW);
 			}
 		}
 		/* Mask out the GCTile change notification, now that we've
@@ -250,7 +250,7 @@ uxa_validate_gc(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
 		 */
 		if (uxa_prepare_access(&pGC->stipple->drawable, UXA_ACCESS_RW)) {
 			fbValidateGC(pGC, changes, pDrawable);
-			uxa_finish_access(&pGC->stipple->drawable);
+			uxa_finish_access(&pGC->stipple->drawable, UXA_ACCESS_RW);
 		}
 	} else {
 		fbValidateGC(pGC, changes, pDrawable);
@@ -296,7 +296,7 @@ Bool uxa_prepare_access_window(WindowPtr pWin)
 		    (&pWin->border.pixmap->drawable, UXA_ACCESS_RO)) {
 			if (pWin->backgroundState == BackgroundPixmap)
 				uxa_finish_access(&pWin->background.pixmap->
-						  drawable);
+						  drawable, UXA_ACCESS_RO);
 			return FALSE;
 		}
 	}
@@ -306,10 +306,10 @@ Bool uxa_prepare_access_window(WindowPtr pWin)
 void uxa_finish_access_window(WindowPtr pWin)
 {
 	if (pWin->backgroundState == BackgroundPixmap)
-		uxa_finish_access(&pWin->background.pixmap->drawable);
+		uxa_finish_access(&pWin->background.pixmap->drawable, UXA_ACCESS_RO);
 
 	if (pWin->borderIsPixel == FALSE)
-		uxa_finish_access(&pWin->border.pixmap->drawable);
+		uxa_finish_access(&pWin->border.pixmap->drawable, UXA_ACCESS_RO);
 }
 
 static Bool uxa_change_window_attributes(WindowPtr pWin, unsigned long mask)
@@ -329,7 +329,7 @@ static RegionPtr uxa_bitmap_to_region(PixmapPtr pPix)
 	if (!uxa_prepare_access(&pPix->drawable, UXA_ACCESS_RO))
 		return NULL;
 	ret = fbPixmapToRegion(pPix);
-	uxa_finish_access(&pPix->drawable);
+	uxa_finish_access(&pPix->drawable, UXA_ACCESS_RO);
 	return ret;
 }
 
diff --git a/uxa/uxa.h b/uxa/uxa.h
index e001c53..66b5f1e 100644
--- a/uxa/uxa.h
+++ b/uxa/uxa.h
@@ -45,7 +45,9 @@
 
 typedef enum {
 	UXA_ACCESS_RO,
-	UXA_ACCESS_RW
+	UXA_ACCESS_RW,
+	UXA_GLAMOR_ACCESS_RO,
+	UXA_GLAMOR_ACCESS_RW
 } uxa_access_t;
 
 /**
@@ -513,7 +515,7 @@ typedef struct _UxaDriver {
 	 * offscreen pixmap set up by prepare_access().  Note that the
 	 * finish_access() will not be called if prepare_access() failed.
 	 */
-	void (*finish_access) (PixmapPtr pPix);
+	void (*finish_access) (PixmapPtr pPix, uxa_access_t access);
 
 	/**
 	 * PixmapIsOffscreen() is an optional driver replacement to
@@ -543,6 +545,13 @@ typedef struct _UxaDriver {
  */
 #define UXA_TWO_BITBLT_DIRECTIONS	(1 << 2)
 
+/**
+ * UXA_USE_GLAMOR indicates to use glamor acceleration to perform rendering.
+ * And if glamor fail to accelerate the rendering, then goto fallback to
+ * use CPU to do the rendering.
+ */
+#define UXA_USE_GLAMOR			(1 << 3)
+
 /** @} */
 
 /** @name UXA CreatePixmap hint flags
-- 
1.7.4.4



[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]
  Powered by Linux