glamor: Move flags check to intel_glamor.
PATCH 1/2 glamor: Move flags check to intel_glamor.
Address Chris comment. We concentrate all the flag check into intel_glamor layer which makes the interface to glamor self-contained.
--- 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(-)
src/Makefile.am +1 -5
@@ -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
src/intel_driver.c +8 -17
@@ -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);
src/intel_glamor.c +66 -9
140 lines not on this page · raw message
src/intel_uxa.c +7 -24
@@ -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; }
Signature · 1 line
1.7.4.4
PATCH 2/2 glamor: Address GLAMOR/UXA flushing problem.
This commit introduces a new function in UXA layer need_flush which is used to let the UXA layer to notify the lower layer that some pixmap get modified by GLAMOR. And then the intel driver could know it need to flush front buffer latter.
This commit also adds some necessary flushing pointis for UXA layer and glamor layer. Basicly, there are three scenarios:
1. Before calling into glamor layer, it needs to flush all the corresponding UXA batch comand buffer.
2. After calling the glamor rendering functions, it needs to flush the pending GL operations.
3. Before we map a pixmap's BO, we also need to flush all the pending GL operations.
The scenario 2 could be eliminated when we fully change to glamor path.
--- src/intel_glamor.c | 13 ++++++++++++- src/intel_uxa.c | 8 +++++++- uxa/uxa-accel.c | 30 ++++++++++++++++++++++++------ uxa/uxa.h | 16 +++++++++++++++- 4 files changed, 58 insertions(+), 9 deletions(-)
src/intel_glamor.c +12 -1
@@ -106,6 +106,16 @@ intel_glamor_destroy_pixmap(PixmapPtr pixmap)glamor_egl_destroy_textured_pixmap (pixmap); } +static void +intel_glamor_need_flush (DrawablePtr pDrawable) +{ +ScrnInfoPtr scrn = xf86Screens[pDrawable->pScreen->myNum]; +intel_screen_private * intel; + + intel =intel_get_screen_private (scrn); + intel->needs_flush = TRUE; +} +Bool intel_glamor_init (ScreenPtr screen) {
@@ -113,7 +123,6 @@ intel_glamor_init(ScreenPtr screen)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" );
@@ -130,6 +139,8 @@ intel_glamor_init(ScreenPtr screen) intel->uxa_driver->flags |=UXA_USE_GLAMOR ; intel->uxa_flags = intel->uxa_driver->flags; + intel->uxa_driver->need_flush = intel_glamor_need_flush; +xf86DrvMsg (scrn->scrnIndex,X_INFO ,"Use GLAMOR acceleration.\n" );return TRUE;
src/intel_uxa.c +7 -1
@@ -705,8 +705,14 @@ static Bool intel_uxa_prepare_access(PixmapPtr pixmap, uxa_access_t access)int ret;if (!list_is_empty (&priv->batch) && - (access ==UXA_ACCESS_RW || priv->batch_write)) + ((access ==UXA_ACCESS_RW || access ==UXA_GLAMOR_ACCESS_RW ) + || priv->batch_write))intel_batch_submit (scrn); + +if (access ==UXA_GLAMOR_ACCESS_RW || access ==UXA_GLAMOR_ACCESS_RO ) +return TRUE; + +intel_glamor_block_handler (intel);if (priv->tiling || bo->size <= intel->max_gtt_map_size) ret =drm_intel_gem_bo_map_gtt (bo);
uxa/uxa-accel.c +24 -6
@@ -56,11 +56,16 @@ uxa_fill_spans(DrawablePtr pDrawable, GCPtr pGC, int n,int x1, x2, y;int off_x, off_y; -if ((uxa_screen->info->flags &UXA_GLAMOR_FLAGS ) - && (glamor_fill_spans_nf (pDrawable, pGC, n, ppt, pwidth, fSorted))) -return ; -else if (uxa_screen->info->flags &UXA_USE_GLAMOR_ONLY ) - goto fallback; +if ((uxa_screen->info->flags &UXA_GLAMOR_FLAGS )) { +uxa_prepare_access (pDrawable,UXA_GLAMOR_ACCESS_RW ); +if (glamor_fill_spans_nf (pDrawable, + pGC, n, ppt, pwidth, fSorted)) { + uxa_screen->info->need_flush (pDrawable); +glamor_block_handler (screen); +return ; + }else if (uxa_screen->info->flags &UXA_USE_GLAMOR_ONLY ) + goto fallback; + }if (uxa_screen->swappedOut || uxa_screen->force_fallback) goto fallback;
@@ -685,9 +690,22 @@ uxa_poly_fill_rect(DrawablePtr pDrawable,int n;RegionPtr pReg =RECTS_TO_REGION (pScreen, nrect, prect,CT_UNSORTED ); +if ((uxa_screen->info->flags &UXA_GLAMOR_FLAGS )) { +uxa_prepare_access (pDrawable,UXA_GLAMOR_ACCESS_RW ); +if (glamor_poly_fill_rect_nf (pDrawable, + pGC, nrect, prect)) { + uxa_screen->info->need_flush (pDrawable); +glamor_block_handler (pDrawable->pScreen); +return ; + }else if (uxa_screen->info->flags &UXA_USE_GLAMOR_ONLY ) + goto fallback; + } +if ((uxa_screen->info->flags &UXA_GLAMOR_FLAGS ) - && (glamor_poly_fill_rect_nf (pDrawable, pGC, nrect, prect))) + && (glamor_poly_fill_rect_nf (pDrawable, pGC, nrect, prect))) { + uxa_screen->info->need_flush (pDrawable);return ; + }else if (uxa_screen->info->flags &UXA_USE_GLAMOR_ONLY ) goto fallback;
uxa/uxa.h +15 -1
@@ -45,7 +45,9 @@typedef enum {UXA_ACCESS_RO , -UXA_ACCESS_RW +UXA_ACCESS_RW , +UXA_GLAMOR_ACCESS_RO , +UXA_GLAMOR_ACCESS_RW }uxa_access_t ;/**
@@ -530,6 +532,18 @@ typedef struct _UxaDriver {*/ Bool (*pixmap_is_offscreen) (PixmapPtr pPix); +/** +* need_flush() is called after Glamor modify a textured pixmap. +* +* @param pDrawable the target drawable. +* +* +* need_flush is used to notify the underlying DDX layer that +* some pixmaps get dirty in glamor access. Thus a render cache +* flushing may be required, especially when the modified pixmap +* is the screen pixmap which is the front buffer. +*/ +void (*need_flush) (DrawablePtr pDrawable);/** @} */ } uxa_driver_t;
Signature · 1 line
1.7.4.4
Re: [PATCH 2/2] glamor: Address GLAMOR/UXA flushing problem.
Quoted 11 lines · Zhigang Gong
This commit introduces a new function in UXA layer
need_flushwhich is used to let the UXA layer to notify the lower layer that some pixmap get modified by GLAMOR. And then the intel driver could know it need to flush front buffer latter.This commit also adds some necessary flushing pointis for UXA layer and glamor layer. Basicly, there are three scenarios:
1. Before calling into glamor layer, it needs to flush all the corresponding UXA batch comand buffer.
Quoted 8 lines
2. After calling the glamor rendering functions, it needs to flush the pending GL operations.
3. Before we map a pixmap's BO, we also need to flush all the pending GL operations.
The scenario 2 could be eliminated when we fully change to glamor path.
I much prefer the one-sided uxa_prepare_access() you have implemented here for the glamor side. For completeness, you still probably want the uxa_finish_access() though. Alternatively you need to mark up all operations with uxa_prepare_access(GLAMOR | NATIVE | SW, READ | WRITE) which then perform the implicit uxa_finish_access() when the mode changes, and would also allow you to only flush the glamor operations as required.
Aside from that, this looks like the right approach to handling the flushing.
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH 2/2] glamor: Address GLAMOR/UXA flushing problem.
Quoted 26 lines
-----Original Message-----
From: Chris Wilson [mailto:[email protected]]
Sent: Tuesday, November 15, 2011 8:25 PM
To: Zhigang Gong; [email protected]
Cc: [email protected]
Subject: Re: [PATCH 2/2] glamor: Address GLAMOR/UXA flushing problem.Quoted 17 lines · Zhigang Gong
This commit introduces a new function in UXA layer
need_flushwhich is used to let the UXA layer to notify the lower layer that some pixmap get modified by GLAMOR. And then the intel driver could know it need to flush front buffer latter.This commit also adds some necessary flushing pointis for UXA layer and glamor layer. Basicly, there are three scenarios:
1. Before calling into glamor layer, it needs to flush all the corresponding UXA batch comand buffer.
2. After calling the glamor rendering functions, it needs to flush the pending GL operations.
3. Before we map a pixmap's BO, we also need to flush all the pending GL operations.
Quoted 6 lines
Quoted 2 lines
The scenario 2 could be eliminated when we fully change to glamor path.
I much prefer the one-sided
uxa_prepare_access()you have implemented here for the glamor side. For completeness, you still probably want theuxa_finish_access()though.
I was thinking about that, but current uxa_finish_access doesn't have a parameter
to indicate the access type. I prefer to change the uxa_finish_access's prototype
to the same as uxa_prepare_access(). And then will do glamor flush there if the
access type is GLAMOR_WRITE. I'm just not very sure whether it is the best way.
Will work out a new patch to implement that soon.
BTW, May I have your review tag in the commits which get reviewed by you. Thanks.
Quoted 5 lines
Alternatively you need to mark up all
operations withuxa_prepare_access(GLAMOR | NATIVE | SW, READ | WRITE)which then perform the implicituxa_finish_access()when the mode changes, and would also allow you to only flush the glamor operations as required.
This looks much complicate than the first solution. I prefer the first solution.
-- Zhigang
Quoted 2 lines
Aside from that, this looks like the right approach to handling the
flushing.
Quoted 4 lines
-Chris
--
Chris Wilson, Intel Open Source Technology Centre
Re: [PATCH 2/2] glamor: Address GLAMOR/UXA flushing problem.
Quoted 2 lines · Zhigang Gong
BTW, May I have your review tag in the commits which get reviewed by you. Thanks.
I'm hoping that you will rebase the series into something that can be cleanly merged - i.e. I don't expect the patches in their current form and order to be applied. ;-)
-Chris
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre
Quoted 3 lines · Zhigang Gong
Address Chris comment. We concentrate all the flag check into
intel_glamorlayer which makes the interface to glamor self-contained.
Thanks, that looks a lot better and makes it much easier to read how glamor is integrated into the driver.
-Chris
Quoted 1 line
Signature · 1 line
Chris Wilson, Intel Open Source Technology Centre