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>
This commit is contained in:
parent
0706423bcf
commit
32a7438bf7
|
@ -225,6 +225,11 @@ glamor_block_handler(ScreenPtr screen)
|
||||||
dispatch->glFlush();
|
dispatch->glFlush();
|
||||||
glamor_fbo_expire(glamor_priv);
|
glamor_fbo_expire(glamor_priv);
|
||||||
glamor_put_dispatch(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
|
static void
|
||||||
|
|
|
@ -137,6 +137,7 @@ glamor_copy_n_to_n_fbo_blit(DrawablePtr src,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
|
glamor_priv->state = BLIT_STATE;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -257,6 +258,8 @@ glamor_copy_n_to_n_textured(DrawablePtr src,
|
||||||
dispatch->glUseProgram(0);
|
dispatch->glUseProgram(0);
|
||||||
/* The source texture is bound to a fbo, we have to flush it here. */
|
/* The source texture is bound to a fbo, we have to flush it here. */
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
|
glamor_priv->state = RENDER_STATE;
|
||||||
|
glamor_priv->render_idle_cnt = 0;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,7 +318,7 @@ __glamor_copy_n_to_n(DrawablePtr src,
|
||||||
dx, dy,
|
dx, dy,
|
||||||
src_pixmap, dst_pixmap);
|
src_pixmap, dst_pixmap);
|
||||||
#ifndef GLAMOR_GLES2
|
#ifndef GLAMOR_GLES2
|
||||||
if ((overlaped
|
if ((overlaped || glamor_priv->state != RENDER_STATE
|
||||||
|| !src_pixmap_priv->base.gl_tex || !dst_pixmap_priv->base.gl_tex)
|
|| !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,
|
&& glamor_copy_n_to_n_fbo_blit(src, dst, gc, box, nbox, dx,
|
||||||
dy)) {
|
dy)) {
|
||||||
|
|
|
@ -259,47 +259,8 @@ _glamor_solid_boxes(PixmapPtr pixmap, BoxPtr box, int nbox, float *color)
|
||||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||||
dispatch->glUseProgram(0);
|
dispatch->glUseProgram(0);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
}
|
glamor_priv->state = RENDER_STATE;
|
||||||
|
glamor_priv->render_idle_cnt = 0;
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
|
|
|
@ -199,7 +199,6 @@ typedef struct {
|
||||||
uint16_t evict;
|
uint16_t evict;
|
||||||
} glamor_glyph_cache_t;
|
} glamor_glyph_cache_t;
|
||||||
|
|
||||||
|
|
||||||
#include "glamor_gl_dispatch.h"
|
#include "glamor_gl_dispatch.h"
|
||||||
|
|
||||||
struct glamor_saved_procs {
|
struct glamor_saved_procs {
|
||||||
|
@ -235,6 +234,11 @@ struct glamor_saved_procs {
|
||||||
#define GLAMOR_TICK_AFTER(t0, t1) \
|
#define GLAMOR_TICK_AFTER(t0, t1) \
|
||||||
(((int)(t1) - (int)(t0)) < 0)
|
(((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 {
|
typedef struct glamor_screen_private {
|
||||||
struct glamor_gl_dispatch _dispatch;
|
struct glamor_gl_dispatch _dispatch;
|
||||||
int yInverted;
|
int yInverted;
|
||||||
|
@ -296,6 +300,8 @@ typedef struct glamor_screen_private {
|
||||||
char delayed_fallback_string[GLAMOR_DELAYED_STRING_MAX + 1];
|
char delayed_fallback_string[GLAMOR_DELAYED_STRING_MAX + 1];
|
||||||
int delayed_fallback_pending;
|
int delayed_fallback_pending;
|
||||||
int flags;
|
int flags;
|
||||||
|
int state;
|
||||||
|
unsigned int render_idle_cnt;
|
||||||
ScreenPtr screen;
|
ScreenPtr screen;
|
||||||
} glamor_screen_private;
|
} glamor_screen_private;
|
||||||
|
|
||||||
|
|
|
@ -1444,6 +1444,8 @@ glamor_composite_with_shader(CARD8 op,
|
||||||
#endif
|
#endif
|
||||||
DEBUGF("finish rendering.\n");
|
DEBUGF("finish rendering.\n");
|
||||||
dispatch->glUseProgram(0);
|
dispatch->glUseProgram(0);
|
||||||
|
glamor_priv->state = RENDER_STATE;
|
||||||
|
glamor_priv->render_idle_cnt = 0;
|
||||||
if (saved_source_format)
|
if (saved_source_format)
|
||||||
source->format = saved_source_format;
|
source->format = saved_source_format;
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
|
@ -1665,6 +1667,7 @@ glamor_composite_clipped_region(CARD8 op,
|
||||||
prect[i].y_dst = box[i].y1;
|
prect[i].y_dst = box[i].y1;
|
||||||
prect[i].width = box[i].x2 - box[i].x1;
|
prect[i].width = box[i].x2 - box[i].x1;
|
||||||
prect[i].height = box[i].y2 - box[i].y1;
|
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,
|
ok = glamor_composite_with_shader(op, temp_src, temp_mask, dest,
|
||||||
temp_src_priv, temp_mask_priv,
|
temp_src_priv, temp_mask_priv,
|
||||||
|
@ -1722,7 +1725,6 @@ _glamor_composite(CARD8 op,
|
||||||
DrawablePtr saved_source_drawable;
|
DrawablePtr saved_source_drawable;
|
||||||
DrawablePtr saved_mask_drawable;
|
DrawablePtr saved_mask_drawable;
|
||||||
int force_clip = 0;
|
int force_clip = 0;
|
||||||
|
|
||||||
dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
|
dest_pixmap_priv = glamor_get_pixmap_private(dest_pixmap);
|
||||||
|
|
||||||
if (source->pDrawable) {
|
if (source->pDrawable) {
|
||||||
|
|
|
@ -185,6 +185,9 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
|
||||||
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
dispatch->glDisableVertexAttribArray(GLAMOR_VERTEX_POS);
|
||||||
dispatch->glUseProgram(0);
|
dispatch->glUseProgram(0);
|
||||||
glamor_put_dispatch(glamor_priv);
|
glamor_put_dispatch(glamor_priv);
|
||||||
|
|
||||||
|
glamor_priv->state = RENDER_STATE;
|
||||||
|
glamor_priv->render_idle_cnt = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Bool
|
Bool
|
||||||
|
|
Loading…
Reference in New Issue
Block a user