glamor: Added flags to indicate whether to use glamor in UXA.
PATCH 1/4 glamor: Added flags to indicate whether to use glamor in UXA.
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.
--- uxa/uxa.h | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-)
uxa/uxa.h +16 -0
@@ -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
Signature · 1 line
1.7.4.4
PATCH 2/4 glamor: Added new data element to track uxa flags in intel structure.
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.
--- src/intel.h | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
src/intel.h +1 -0
@@ -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;
Signature · 1 line
1.7.4.4
PATCH 3/4 glamor: check a flag to indicate whether enable GLAMOR.
In reply to Zhigang GongAccording 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.
--- src/intel_driver.c | 12 ++++++------ src/intel_uxa.c | 38 ++++++++++++++++++++++++-------------- uxa/uxa-accel.c | 16 ++++++++++------ 3 files changed, 40 insertions(+), 26 deletions(-)
src/intel_driver.c +6 -6
@@ -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);
src/intel_uxa.c +24 -14
@@ -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; }
uxa/uxa-accel.c +10 -6
@@ -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);
Signature · 1 line
1.7.4.4
Re: [PATCH 3/4] glamor: check a flag to indicate whether enable GLAMOR.
Quoted 5 lines · Zhigang Gong
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
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
PATCH 4/4 glamor: Silence compilation warnings.
In reply to Zhigang GongAs 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.
--- src/intel_driver.c | 2 -- src/intel_uxa.c | 2 -- uxa/uxa-accel.c | 5 ++++- 3 files changed, 4 insertions(+), 5 deletions(-)
src/intel_driver.c +0 -2
@@ -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* */ /*
src/intel_uxa.c +0 -2
@@ -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 */
uxa/uxa-accel.c +4 -1
@@ -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,
Signature · 1 line
1.7.4.4