diff options
author | Zhigang Gong <zhigang.gong@linux.intel.com> | 2012-07-03 18:24:07 +0800 |
---|---|---|
committer | Eric Anholt <eric@anholt.net> | 2013-12-18 11:23:53 -0800 |
commit | 32a7438bf79573100862ad91c5722d12623a8bf9 (patch) | |
tree | d57bc3ce02e8bc4d1186602c7fe81ede624306cc | |
parent | 0706423bcfd7a589bab3b41fe9f13d0b636ecdef (diff) |
glamor_copyarea: Use blitcopy if current state is not render.
Practically, for pure 2D blit, the blit copy is much faster
than textured copy. For the x11perf copywinwin100, it's about
3x faster. But if we have heavy rendering/compositing, then use
textured copy will get much better (>30%)performance for most
of the cases.
So we simply add a data element to track current state. For
rendering state we use textured copy, otherwise, we use blit
copy.
Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
-rw-r--r-- | glamor/glamor.c | 5 | ||||
-rw-r--r-- | glamor/glamor_copyarea.c | 5 | ||||
-rw-r--r-- | glamor/glamor_fill.c | 43 | ||||
-rw-r--r-- | glamor/glamor_priv.h | 8 | ||||
-rw-r--r-- | glamor/glamor_render.c | 4 | ||||
-rw-r--r-- | glamor/glamor_tile.c | 3 |
6 files changed, 24 insertions, 44 deletions
diff --git a/glamor/glamor.c b/glamor/glamor.c index 01f6a9a8f..8b7dc930d 100644 --- a/glamor/glamor.c +++ b/glamor/glamor.c @@ -225,6 +225,11 @@ glamor_block_handler(ScreenPtr screen) dispatch->glFlush(); glamor_fbo_expire(glamor_priv); glamor_put_dispatch(glamor_priv); + if (glamor_priv->state == RENDER_STATE + && glamor_priv->render_idle_cnt++ > RENDER_IDEL_MAX) { + glamor_priv->state = IDLE_STATE; + glamor_priv->render_idle_cnt = 0; + } } static void diff --git a/glamor/glamor_copyarea.c b/glamor/glamor_copyarea.c index ee6f8120f..299417927 100644 --- a/glamor/glamor_copyarea.c +++ b/glamor/glamor_copyarea.c @@ -137,6 +137,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src, } } glamor_put_dispatch(glamor_priv); + glamor_priv->state = BLIT_STATE; return TRUE; } #endif @@ -257,6 +258,8 @@ glamor_copy_n_to_n_textured(DrawablePtr src, dispatch->glUseProgram(0); /* The source texture is bound to a fbo, we have to flush it here. */ glamor_put_dispatch(glamor_priv); + glamor_priv->state = RENDER_STATE; + glamor_priv->render_idle_cnt = 0; return TRUE; } @@ -315,7 +318,7 @@ __glamor_copy_n_to_n(DrawablePtr src, dx, dy, src_pixmap, dst_pixmap); #ifndef GLAMOR_GLES2 - if ((overlaped + if ((overlaped || glamor_priv->state != RENDER_STATE || !src_pixmap_priv->base.gl_tex || !dst_pixmap_priv->base.gl_tex) && glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx, dy)) { diff --git a/glamor/glamor_fill.c b/glamor/glamor_fill.c index 2163c9461..1d81aea52 100644 --- a/glamor/glamor_fill.c +++ b/glamor/glamor_fill.c @@ -259,47 +259,8 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color) dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS); dispatch->glUseProgram(0); glamor_put_dispatch(glamor_priv); -} - -static void -_glamor_solid(PixmapPtr pixmap, int x, int y, int width, int height, - float *color) -{ - ScreenPtr screen = pixmap->drawable.pScreen; - glamor_screen_private *glamor_priv = - glamor_get_screen_private(screen); - glamor_pixmap_private *pixmap_priv = - glamor_get_pixmap_private(pixmap); - glamor_gl_dispatch *dispatch; - int x1 = x; - int x2 = x + width; - int y1 = y; - int y2 = y + height; - float vertices[8]; - GLfloat xscale, yscale; - - glamor_set_destination_pixmap_priv_nc(pixmap_priv); - - dispatch = glamor_get_dispatch(glamor_priv); - dispatch->glUseProgram(glamor_priv->solid_prog); - - dispatch->glUniform4fv(glamor_priv->solid_color_uniform_location, - 1, color); - - dispatch->glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, GL_FLOAT, - GL_FALSE, 2 * sizeof(float), - vertices); - dispatch->glEnableVertexAttribArray(GLAMOR_VERTEX_POS); - pixmap_priv_get_dest_scale(pixmap_priv, &xscale, &yscale); - - glamor_set_normalize_vcoords(pixmap_priv, xscale, yscale, - x1, y1, - x2, y2, - glamor_priv->yInverted, vertices); - dispatch->glDrawArrays(GL_TRIANGLE_FAN, 0, 4); - dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS); - dispatch->glUseProgram(0); - glamor_put_dispatch(glamor_priv); + glamor_priv->state = RENDER_STATE; + glamor_priv->render_idle_cnt = 0; } Bool diff --git a/glamor/glamor_priv.h b/glamor/glamor_priv.h index a7d4fe783..0703c076d 100644 --- a/glamor/glamor_priv.h +++ b/glamor/glamor_priv.h @@ -199,7 +199,6 @@ typedef struct { uint16_t evict; } glamor_glyph_cache_t; - #include "glamor_gl_dispatch.h" struct glamor_saved_procs { @@ -235,6 +234,11 @@ struct glamor_saved_procs { #define GLAMOR_TICK_AFTER(t0, t1) \ (((int)(t1) - (int)(t0)) < 0) +#define IDLE_STATE 0 +#define RENDER_STATE 1 +#define BLIT_STATE 2 +#define RENDER_IDEL_MAX 32 + typedef struct glamor_screen_private { struct glamor_gl_dispatch _dispatch; int yInverted; @@ -296,6 +300,8 @@ typedef struct glamor_screen_private { char delayed_fallback_string[GLAMOR_DELAYED_STRING_MAX + 1]; int delayed_fallback_pending; int flags; + int state; + unsigned int render_idle_cnt; ScreenPtr screen; } glamor_screen_private; diff --git a/glamor/glamor_render.c b/glamor/glamor_render.c index b82c7c327..60fc2f658 100644 --- a/glamor/glamor_render.c +++ b/glamor/glamor_render.c @@ -1444,6 +1444,8 @@ glamor_composite_with_shader(CARD8 op, #endif DEBUGF("finish rendering.\n"); dispatch->glUseProgram(0); + glamor_priv->state = RENDER_STATE; + glamor_priv->render_idle_cnt = 0; if (saved_source_format) source->format = saved_source_format; glamor_put_dispatch(glamor_priv); @@ -1665,6 +1667,7 @@ glamor_composite_clipped_region(CARD8 op, prect[i].y_dst = box[i].y1; prect[i].width = box[i].x2 - box[i].x1; prect[i].height = box[i].y2 - box[i].y1; + DEBUGF("dest %d %d \n", prect[i].x_dst, prect[i].y_dst); } ok = glamor_composite_with_shader(op, temp_src, temp_mask, dest, temp_src_priv, temp_mask_priv, @@ -1722,7 +1725,6 @@ _glamor_composite(CARD8 op, DrawablePtr saved_source_drawable; DrawablePtr saved_mask_drawable; int force_clip = 0; - dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap); if (source->pDrawable) { diff --git a/glamor/glamor_tile.c b/glamor/glamor_tile.c index 7809e8bf8..60486cfc0 100644 --- a/glamor/glamor_tile.c +++ b/glamor/glamor_tile.c @@ -185,6 +185,9 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile, dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS); dispatch->glUseProgram(0); glamor_put_dispatch(glamor_priv); + + glamor_priv->state = RENDER_STATE; + glamor_priv->render_idle_cnt = 0; } Bool |