summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorZhigang Gong <zhigang.gong@linux.intel.com>2012-07-03 18:24:07 +0800
committerZhigang Gong <zhigang.gong@linux.intel.com>2012-07-11 15:07:38 +0800
commit73d33dd2400772ad47a57dad2c2fa93caebccc80 (patch)
treeff8ea31d8ac0d9290a108dcc85f722c64350a3e3
parent1ec81c73bf4660d87b9cfa281647ca6cbda68f2e (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--src/glamor.c5
-rw-r--r--src/glamor_copyarea.c5
-rw-r--r--src/glamor_fill.c43
-rw-r--r--src/glamor_priv.h8
-rw-r--r--src/glamor_render.c4
-rw-r--r--src/glamor_tile.c3
6 files changed, 24 insertions, 44 deletions
diff --git a/src/glamor.c b/src/glamor.c
index 01f6a9a..8b7dc93 100644
--- a/src/glamor.c
+++ b/src/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/src/glamor_copyarea.c b/src/glamor_copyarea.c
index ee6f812..2994179 100644
--- a/src/glamor_copyarea.c
+++ b/src/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/src/glamor_fill.c b/src/glamor_fill.c
index 2163c94..1d81aea 100644
--- a/src/glamor_fill.c
+++ b/src/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/src/glamor_priv.h b/src/glamor_priv.h
index a7d4fe7..0703c07 100644
--- a/src/glamor_priv.h
+++ b/src/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/src/glamor_render.c b/src/glamor_render.c
index b82c7c3..60fc2f6 100644
--- a/src/glamor_render.c
+++ b/src/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/src/glamor_tile.c b/src/glamor_tile.c
index 7809e8b..60486cf 100644
--- a/src/glamor_tile.c
+++ b/src/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