[Intel-gfx] [PATCH 3/4] glamor: check a flag to indicate whether enable GLAMOR.

Zhigang Gong zhigang.gong at linux.intel.com
Mon Nov 14 13:09:03 CET 2011


According to Chris's comments, this commit try to
elminate #ifdef from the body of the code if possible.
We check the flags to determine whether enable GLAMOR
at runtime, rather than check the MACRO during the compile
time.

Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 src/intel_driver.c |   12 ++++++------
 src/intel_uxa.c    |   38 ++++++++++++++++++++++++--------------
 uxa/uxa-accel.c    |   16 ++++++++++------
 3 files changed, 40 insertions(+), 26 deletions(-)

diff --git a/src/intel_driver.c b/src/intel_driver.c
index 63f83e7..bd57694 100644
--- a/src/intel_driver.c
+++ b/src/intel_driver.c
@@ -1127,9 +1127,10 @@ static void I830FreeScreen(int scrnIndex, int flags)
 {
 	ScrnInfoPtr scrn = xf86Screens[scrnIndex];
 	intel_screen_private *intel = intel_get_screen_private(scrn);
-#ifdef GLAMOR
-	intel_glamor_free_screen(scrnIndex, flags);
-#endif
+
+	if (intel->uxa_flags & UXA_GLAMOR_FLAGS)
+		intel_glamor_free_screen(scrnIndex, flags);
+
 	if (intel) {
 		intel_mode_fini(intel);
 		intel_close_drm_master(intel);
@@ -1209,9 +1210,8 @@ static Bool I830CloseScreen(int scrnIndex, ScreenPtr screen)
 
 	DeleteCallback(&FlushCallback, intel_flush_callback, scrn);
 
-#ifdef GLAMOR
-	intel_glamor_close_screen(screen);
-#endif
+	if (intel->uxa_flags & UXA_GLAMOR_FLAGS)
+		intel_glamor_close_screen(screen);
 
 	if (intel->uxa_driver) {
 		uxa_driver_fini(screen);
diff --git a/src/intel_uxa.c b/src/intel_uxa.c
index 3bbe531..a069980 100644
--- a/src/intel_uxa.c
+++ b/src/intel_uxa.c
@@ -968,9 +968,8 @@ void intel_uxa_block_handler(intel_screen_private *intel)
 	 * and beyond rendering results may not hit the
 	 * framebuffer until significantly later.
 	 */
-#ifdef GLAMOR
-	intel_glamor_block_handler(intel);
-#endif
+	if (intel->uxa_flags & UXA_GLAMOR_FLAGS)
+		intel_glamor_block_handler(intel);
 	intel_flush_rendering(intel);
 }
 
@@ -1102,10 +1101,11 @@ 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);
-#ifdef GLAMOR
-		priv->pinned = 1;
-		intel_glamor_create_textured_pixmap(pixmap);
-#endif
+
+		if (intel->uxa_flags & UXA_GLAMOR_FLAGS) {
+			priv->pinned = 1;
+			intel_glamor_create_textured_pixmap(pixmap);
+		}
 	}
 
 	return pixmap;
@@ -1113,10 +1113,11 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 
 static Bool intel_uxa_destroy_pixmap(PixmapPtr pixmap)
 {
+	ScrnInfoPtr scrn = xf86Screens[pixmap->drawable.pScreen->myNum];
+	intel_screen_private *intel = intel_get_screen_private(scrn);
 	if (pixmap->refcnt == 1) {
-#ifdef GLAMOR
-		intel_glamor_destroy_pixmap(pixmap);
-#endif
+		if (intel->uxa_flags & UXA_GLAMOR_FLAGS)
+			intel_glamor_destroy_pixmap(pixmap);
 		intel_set_pixmap_bo(pixmap, NULL);
 	}
 	fbDestroyPixmap(pixmap);
@@ -1149,10 +1150,10 @@ Bool intel_uxa_create_screen_resources(ScreenPtr screen)
 		scrn->displayWidth = intel->front_pitch / intel->cpp;
 	}
 
-#ifdef GLAMOR
-	if (!intel_glamor_create_screen_resources(screen))
+	if ((intel->uxa_flags & UXA_GLAMOR_FLAGS)
+	    && !intel_glamor_create_screen_resources(screen))
 		return FALSE;
-#endif
+
 	return TRUE;
 }
 
@@ -1315,7 +1316,16 @@ Bool intel_uxa_init(ScreenPtr screen)
 	uxa_set_fallback_debug(screen, intel->fallback_debug);
 	uxa_set_force_fallback(screen, intel->force_fallback);
 #ifdef GLAMOR
-	intel_glamor_init(screen);
+	if (intel_glamor_init(screen)) {
+		xf86DrvMsg(scrn->scrnIndex, X_INFO,
+			   "Intel GLAMOR initialization successfully.\n");
+		intel->uxa_driver->flags |= UXA_USE_GLAMOR;
+		intel->uxa_flags = intel->uxa_driver->flags;
+	} else {
+		xf86DrvMsg(scrn->scrnIndex, X_WARNING,
+			   "Intel GLAMOR initialization failed," 
+			   "change to use standard UXA.\n");
+	}
 #endif
 	return TRUE;
 }
diff --git a/uxa/uxa-accel.c b/uxa/uxa-accel.c
index 18fa63b..b2e5347 100644
--- a/uxa/uxa-accel.c
+++ b/uxa/uxa-accel.c
@@ -52,10 +52,12 @@ uxa_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int n,
 	int nbox;
 	int x1, x2, y;
 	int off_x, off_y;
-#ifdef GLAMOR
-	if (glamor_fill_spans_nf(pDrawable, pGC, n, ppt, pwidth, fSorted))
+
+	if ((uxa_screen->info->flags & UXA_GLAMOR_FLAGS)
+	    && (glamor_fill_spans_nf(pDrawable, pGC, n, ppt, pwidth, fSorted)))
 		return;
-#endif
+	else if(uxa_screen->info->flags & UXA_USE_GLAMOR_ONLY)
+		goto fallback;
 
 	if (uxa_screen->swappedOut || uxa_screen->force_fallback)
 		goto fallback;
@@ -680,10 +682,12 @@ uxa_poly_fill_rect(DrawablePtr pDrawable,
 	int n;
 	RegionPtr pReg = RECTS_TO_REGION(pScreen, nrect, prect, CT_UNSORTED);
 
-#ifdef GLAMOR
-	if (glamor_poly_fill_rect_nf(pDrawable, pGC, nrect, prect))
+	if ((uxa_screen->info->flags & UXA_GLAMOR_FLAGS)
+	    && (glamor_poly_fill_rect_nf(pDrawable, pGC, nrect, prect)))
 		return;
-#endif
+	else if(uxa_screen->info->flags & UXA_USE_GLAMOR_ONLY)
+		goto fallback;
+
 	/* Compute intersection of rects and clip region */
 	REGION_TRANSLATE(pScreen, pReg, pDrawable->x, pDrawable->y);
 	REGION_INTERSECT(pScreen, pReg, pClip, pReg);
-- 
1.7.4.4




More information about the Intel-gfx mailing list