From: Zhigang Gong <zhigang.gong@linux.intel.com>
To: intel-gfx@lists.freedesktop.org
Subject: [PATCH 3/4] glamor: check a flag to indicate whether enable GLAMOR.
Date: Mon, 14 Nov 2011 20:09:03 +0800 [thread overview]
Message-ID: <1321272544-29722-3-git-send-email-zhigang.gong@linux.intel.com> (raw)
In-Reply-To: <1321272544-29722-1-git-send-email-zhigang.gong@linux.intel.com>
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
next prev parent reply other threads:[~2011-11-14 12:20 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2011-11-14 14:47 ` [PATCH 3/4] glamor: check a flag to indicate whether enable GLAMOR Chris Wilson
2011-11-14 12:09 ` [PATCH 4/4] glamor: Silence compilation warnings Zhigang Gong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1321272544-29722-3-git-send-email-zhigang.gong@linux.intel.com \
--to=zhigang.gong@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox