public inbox for intel-gfx@lists.freedesktop.org
 help / color / mirror / Atom feed
* [PATCH 1/4] glamor: Added flags to indicate whether to use glamor in UXA.
@ 2011-11-14 12:09 Zhigang Gong
  2011-11-14 12:09 ` [PATCH 2/4] glamor: Added new data element to track uxa flags in intel structure Zhigang Gong
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Zhigang Gong @ 2011-11-14 12:09 UTC (permalink / raw)
  To: intel-gfx

Added two new flags UXA_USE_GLAMOR and UXA_USE_GLAMOR_ONLY.
When UXA_USE_GLAMOR or UXA_USE_GLAMOR_ONLY is set, then it
will use GLAMOR to perform rendering operations by default.
If GLAMOR failed to accelerate the operation and UXA_USE_GLAMOR
is set, it then continue to the normal UXA code path to do
the rendering. If the UXA_USE_GLAMOR_ONLY is set, it then
jump to fallback path directly and avoid the UXA acceleration
code.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
---
 uxa/uxa.h |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/uxa/uxa.h b/uxa/uxa.h
index e001c53..21e6f2a 100644
--- a/uxa/uxa.h
+++ b/uxa/uxa.h
@@ -543,6 +543,22 @@ typedef struct _UxaDriver {
  */
 #define UXA_TWO_BITBLT_DIRECTIONS	(1 << 2)
 
+/**
+ * UXA_USE_GLAMOR indicates to use glamor acceleration to perform rendering
+ * as first choice. And if glamor fail to accelerate the rendering, then goto
+ * normal path to do the rendering.
+ */
+#define UXA_USE_GLAMOR			(1 << 3)
+
+/**
+ * UXA_USE_GLAMOR_ONLY 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_ONLY		(1 << 4)
+
+#define UXA_GLAMOR_FLAGS		(UXA_USE_GLAMOR | UXA_USE_GLAMOR_ONLY)
+
 /** @} */
 
 /** @name UXA CreatePixmap hint flags
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/4] glamor: Added new data element to track uxa flags in intel structure.
  2011-11-14 12:09 [PATCH 1/4] glamor: Added flags to indicate whether to use glamor in UXA Zhigang Gong
@ 2011-11-14 12:09 ` Zhigang Gong
  2011-11-14 12:09 ` [PATCH 3/4] glamor: check a flag to indicate whether enable GLAMOR Zhigang Gong
  2011-11-14 12:09 ` [PATCH 4/4] glamor: Silence compilation warnings Zhigang Gong
  2 siblings, 0 replies; 5+ messages in thread
From: Zhigang Gong @ 2011-11-14 12:09 UTC (permalink / raw)
  To: intel-gfx

As uxa_driver may be released before the last call to freeScreen
and destroy the last pixmap, we have to introduce a new flag in
intel structure to indicate whether we are using GLAMOR. This
intel->uxa_flag is a clone of intel->uxa_driver->flags element.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
---
 src/intel.h |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

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;
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 3/4] glamor: check a flag to indicate whether enable GLAMOR.
  2011-11-14 12:09 [PATCH 1/4] glamor: Added flags to indicate whether to use glamor in UXA Zhigang Gong
  2011-11-14 12:09 ` [PATCH 2/4] glamor: Added new data element to track uxa flags in intel structure Zhigang Gong
@ 2011-11-14 12:09 ` Zhigang Gong
  2011-11-14 14:47   ` Chris Wilson
  2011-11-14 12:09 ` [PATCH 4/4] glamor: Silence compilation warnings Zhigang Gong
  2 siblings, 1 reply; 5+ messages in thread
From: Zhigang Gong @ 2011-11-14 12:09 UTC (permalink / raw)
  To: intel-gfx

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@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

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 4/4] glamor: Silence compilation warnings.
  2011-11-14 12:09 [PATCH 1/4] glamor: Added flags to indicate whether to use glamor in UXA Zhigang Gong
  2011-11-14 12:09 ` [PATCH 2/4] glamor: Added new data element to track uxa flags in intel structure Zhigang Gong
  2011-11-14 12:09 ` [PATCH 3/4] glamor: check a flag to indicate whether enable GLAMOR Zhigang Gong
@ 2011-11-14 12:09 ` Zhigang Gong
  2 siblings, 0 replies; 5+ messages in thread
From: Zhigang Gong @ 2011-11-14 12:09 UTC (permalink / raw)
  To: intel-gfx

As we removed those #ifdef from the body of the code, some
functions are referenced even we haven't defined the GLAMOR
though those functions are never be called at run time. We
still need to inclue those prototypes or make a fake function
to silcent the compilation warnings.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
---
 src/intel_driver.c |    2 --
 src/intel_uxa.c    |    2 --
 uxa/uxa-accel.c    |    5 ++++-
 3 files changed, 4 insertions(+), 5 deletions(-)

diff --git a/src/intel_driver.c b/src/intel_driver.c
index bd57694..0f528f3 100644
--- a/src/intel_driver.c
+++ b/src/intel_driver.c
@@ -75,9 +75,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "i915_drm.h"
 #include <xf86drmMode.h>
 
-#ifdef GLAMOR
 #include "intel_glamor.h"
-#endif
 
 /* *INDENT-OFF* */
 /*
diff --git a/src/intel_uxa.c b/src/intel_uxa.c
index a069980..81d5ec0 100644
--- a/src/intel_uxa.c
+++ b/src/intel_uxa.c
@@ -40,9 +40,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include <string.h>
 #include <errno.h>
 
-#ifdef GLAMOR
 #include "intel_glamor.h"
-#endif
 
 static const int I830CopyROP[16] = {
 	ROP_0,			/* GXclear */
diff --git a/uxa/uxa-accel.c b/uxa/uxa-accel.c
index b2e5347..5b27aaa 100644
--- a/uxa/uxa-accel.c
+++ b/uxa/uxa-accel.c
@@ -38,7 +38,10 @@
 
 #ifdef GLAMOR
 #include "glamor.h"
-#endif
+#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,
-- 
1.7.4.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 3/4] glamor: check a flag to indicate whether enable GLAMOR.
  2011-11-14 12:09 ` [PATCH 3/4] glamor: check a flag to indicate whether enable GLAMOR Zhigang Gong
@ 2011-11-14 14:47   ` Chris Wilson
  0 siblings, 0 replies; 5+ messages in thread
From: Chris Wilson @ 2011-11-14 14:47 UTC (permalink / raw)
  To: Zhigang Gong, intel-gfx

On Mon, 14 Nov 2011 20:09:03 +0800, Zhigang Gong <zhigang.gong@linux.intel.com> wrote:
> 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.

I was thinking more along the lines of pushing the actual check out of
I830CloseScreen (and friends) and into the intel_glamor routines. That
way the interface to glamor is fairly self-contained and the existing code
can be gradually whittled away until it is simply a call into
intel_glamor, at which point we can remove the existing layer.

Inside uxa, the inline checks are indeed better as this layer should be
tightly integrated with the available acceleration methods.
-Chris

-- 
Chris Wilson, Intel Open Source Technology Centre

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2011-11-14 14:47 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-11-14 12:09 [PATCH 1/4] glamor: Added flags to indicate whether to use glamor in UXA Zhigang Gong
2011-11-14 12:09 ` [PATCH 2/4] glamor: Added new data element to track uxa flags in intel structure Zhigang Gong
2011-11-14 12:09 ` [PATCH 3/4] glamor: check a flag to indicate whether enable GLAMOR Zhigang Gong
2011-11-14 14:47   ` Chris Wilson
2011-11-14 12:09 ` [PATCH 4/4] glamor: Silence compilation warnings Zhigang Gong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox