[PATCH 1/2] glamor: Move flags check to intel_glamor.

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

 



Address Chris comment. We concentrate all the flag check into
intel_glamor layer which makes the interface to glamor
self-contained.

Signed-off-by: Zhigang Gong <zhigang.gong at linux.intel.com>
---
 src/Makefile.am    |    6 +---
 src/intel_driver.c |   25 +++++------------
 src/intel_glamor.c |   75 +++++++++++++++++++++++++++++++++++++++++++++------
 src/intel_uxa.c    |   31 +++++----------------
 4 files changed, 82 insertions(+), 55 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_driver.c b/src/intel_driver.c
index 0f528f3..2cc418e 100644
--- a/src/intel_driver.c
+++ b/src/intel_driver.c
@@ -714,19 +714,12 @@ static Bool I830PreInit(ScrnInfoPtr scrn, int flags)
 		return FALSE;
 	}
 
-#ifdef GLAMOR
-        /* Load glamor module */
-        if (!xf86LoadSubModule(scrn, "glamor_egl")) {
-                PreInitCleanup(scrn);
-                return FALSE;
-        }
-
-        if (!intel_glamor_pre_init(scrn)) {
-               xf86DrvMsg(scrn->scrnIndex, X_ERROR,
-                          "Failed to pre init glamor display.\n");
-               return FALSE;
-        }
-#endif
+	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)
@@ -1126,8 +1119,7 @@ static void I830FreeScreen(int scrnIndex, int flags)
 	ScrnInfoPtr scrn = xf86Screens[scrnIndex];
 	intel_screen_private *intel = intel_get_screen_private(scrn);
 
-	if (intel->uxa_flags & UXA_GLAMOR_FLAGS)
-		intel_glamor_free_screen(scrnIndex, flags);
+	intel_glamor_free_screen(scrnIndex, flags);
 
 	if (intel) {
 		intel_mode_fini(intel);
@@ -1208,8 +1200,7 @@ static Bool I830CloseScreen(int scrnIndex, ScreenPtr screen)
 
 	DeleteCallback(&FlushCallback, intel_flush_callback, scrn);
 
-	if (intel->uxa_flags & UXA_GLAMOR_FLAGS)
-		intel_glamor_close_screen(screen);
+	intel_glamor_close_screen(screen);
 
 	if (intel->uxa_driver) {
 		uxa_driver_fini(screen);
diff --git a/src/intel_glamor.c b/src/intel_glamor.c
index cadfc71..80cde40 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_GLAMOR_FLAGS))
+		return TRUE;
+
 	if (!glamor_glyphs_init(screen))
 		return FALSE;
 	if (!glamor_egl_create_textured_screen(screen,
@@ -60,57 +63,100 @@ 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_GLAMOR_FLAGS)
+	     && 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_GLAMOR_FLAGS)
+		glamor_egl_destroy_textured_pixmap(pixmap);
 }
 
 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;
+
+	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)
 {
 	ScreenPtr screen = screenInfo.screens[intel->scrn->scrnIndex];
-	glamor_block_handler(screen);
+
+	if (intel->uxa_flags & UXA_GLAMOR_FLAGS)
+		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 +166,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_GLAMOR_FLAGS))
+		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_GLAMOR_FLAGS))
+		glamor_egl_free_screen(scrnIndex, GLAMOR_EGL_EXTERNAL_BUFFER);
 }
diff --git a/src/intel_uxa.c b/src/intel_uxa.c
index 81d5ec0..5202076 100644
--- a/src/intel_uxa.c
+++ b/src/intel_uxa.c
@@ -966,8 +966,7 @@ void intel_uxa_block_handler(intel_screen_private *intel)
 	 * and beyond rendering results may not hit the
 	 * framebuffer until significantly later.
 	 */
-	if (intel->uxa_flags & UXA_GLAMOR_FLAGS)
-		intel_glamor_block_handler(intel);
+	intel_glamor_block_handler(intel);
 	intel_flush_rendering(intel);
 }
 
@@ -1100,10 +1099,7 @@ intel_uxa_create_pixmap(ScreenPtr screen, int w, int h, int depth,
 		list_init(&priv->flush);
 		intel_set_pixmap_private(pixmap, priv);
 
-		if (intel->uxa_flags & UXA_GLAMOR_FLAGS) {
-			priv->pinned = 1;
-			intel_glamor_create_textured_pixmap(pixmap);
-		}
+		intel_glamor_create_textured_pixmap(pixmap);
 	}
 
 	return pixmap;
@@ -1111,11 +1107,8 @@ 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) {
-		if (intel->uxa_flags & UXA_GLAMOR_FLAGS)
-			intel_glamor_destroy_pixmap(pixmap);
+		intel_glamor_destroy_pixmap(pixmap);
 		intel_set_pixmap_bo(pixmap, NULL);
 	}
 	fbDestroyPixmap(pixmap);
@@ -1148,8 +1141,7 @@ Bool intel_uxa_create_screen_resources(ScreenPtr screen)
 		scrn->displayWidth = intel->front_pitch / intel->cpp;
 	}
 
-	if ((intel->uxa_flags & UXA_GLAMOR_FLAGS)
-	    && !intel_glamor_create_screen_resources(screen))
+	if (!intel_glamor_create_screen_resources(screen))
 		return FALSE;
 
 	return TRUE;
@@ -1313,17 +1305,8 @@ Bool intel_uxa_init(ScreenPtr screen)
 
 	uxa_set_fallback_debug(screen, intel->fallback_debug);
 	uxa_set_force_fallback(screen, intel->force_fallback);
-#ifdef GLAMOR
-	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
+
+	intel_glamor_init(screen);
+
 	return TRUE;
 }
-- 
1.7.4.4



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