glamor_emit_composite_vert: Optimize to don't do two times vert coping.

We change some macros to put the vert to the vertex buffer
directly when we cacluating it. This way, we can get about
4% performance gain.

This commit also fixed one RepeatPad bug, when we RepeatPad
a not eaxct size fbo. We need to calculate the edge. The edge
should be 1.0 - half point, not 1.0.

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
Zhigang Gong 2012-06-15 09:03:42 +08:00 committed by Eric Anholt
parent 8656ddbbe7
commit c41d5c79e7
3 changed files with 227 additions and 148 deletions

View File

@ -82,20 +82,20 @@ glamor_create_composite_fs(glamor_gl_dispatch * dispatch,
"uniform int mask_repeat_mode;\n";
const char *relocate_texture =
GLAMOR_DEFAULT_PRECISION
"vec2 rel_tex_coord(vec2 texture, vec2 wh, int repeat) \n"
"vec2 rel_tex_coord(vec2 texture, vec4 wh, int repeat) \n"
"{\n"
" vec2 rel_tex; \n"
" rel_tex = texture * wh; \n"
" rel_tex = texture * wh.xy; \n"
" if (repeat == RepeatNone)\n"
" return rel_tex; \n"
" else if (repeat == RepeatNormal) \n"
" rel_tex = floor(rel_tex) + (fract(rel_tex) / wh); \n"
" rel_tex = floor(rel_tex) + (fract(rel_tex) / wh.xy); \n"
" else if(repeat == RepeatPad) { \n"
" if (rel_tex.x > 1.0) rel_tex.x = 1.0; \n"
" else if(rel_tex.x < 0.0) rel_tex.x = 0.0; \n"
" if (rel_tex.y > 1.0) rel_tex.y = 1.0; \n"
" if (rel_tex.x >= 1.0) rel_tex.x = 1.0 - wh.z * wh.x / 2.; \n"
" else if(rel_tex.x < 0.0) rel_tex.x = 0.0; \n"
" if (rel_tex.y >= 1.0) rel_tex.y = 1.0 - wh.w * wh.y / 2.; \n"
" else if(rel_tex.y < 0.0) rel_tex.y = 0.0; \n"
" rel_tex = rel_tex / wh; \n"
" rel_tex = rel_tex / wh.xy; \n"
" } \n"
" else if(repeat == RepeatReflect) {\n"
" if ((1.0 - mod(abs(floor(rel_tex.x)), 2.0)) < 0.001)\n"
@ -112,14 +112,14 @@ glamor_create_composite_fs(glamor_gl_dispatch * dispatch,
/* The texture and the pixmap size is not match eaxctly, so can't sample it directly.
* rel_sampler will recalculate the texture coords.*/
const char *rel_sampler =
" vec4 rel_sampler(sampler2D tex_image, vec2 tex, vec2 wh, int repeat, int set_alpha)\n"
" vec4 rel_sampler(sampler2D tex_image, vec2 tex, vec4 wh, int repeat, int set_alpha)\n"
"{\n"
" tex = rel_tex_coord(tex, wh, repeat - RepeatFix);\n"
" if (repeat == RepeatFix) {\n"
" if (!(tex.x >= 0.0 && tex.x <= 1.0 \n"
" && tex.y >= 0.0 && tex.y <= 1.0))\n"
" if (!(tex.x >= 0.0 && tex.x < 1.0 \n"
" && tex.y >= 0.0 && tex.y < 1.0))\n"
" return vec4(0.0, 0.0, 0.0, set_alpha);\n"
" tex = (fract(tex) / wh);\n"
" tex = (fract(tex) / wh.xy);\n"
" }\n"
" if (set_alpha != 1)\n"
" return texture2D(tex_image, tex);\n"
@ -135,7 +135,7 @@ glamor_create_composite_fs(glamor_gl_dispatch * dispatch,
GLAMOR_DEFAULT_PRECISION
"varying vec2 source_texture;\n"
"uniform sampler2D source_sampler;\n"
"uniform vec2 source_wh;"
"uniform vec4 source_wh;"
"vec4 get_source()\n"
"{\n"
" if (source_repeat_mode < RepeatFix)\n"
@ -147,7 +147,7 @@ glamor_create_composite_fs(glamor_gl_dispatch * dispatch,
const char *source_pixmap_fetch =
GLAMOR_DEFAULT_PRECISION "varying vec2 source_texture;\n"
"uniform sampler2D source_sampler;\n"
"uniform vec2 source_wh;\n"
"uniform vec4 source_wh;\n"
"vec4 get_source()\n"
"{\n"
" if (source_repeat_mode < RepeatFix) \n"
@ -162,7 +162,7 @@ glamor_create_composite_fs(glamor_gl_dispatch * dispatch,
const char *mask_alpha_pixmap_fetch =
GLAMOR_DEFAULT_PRECISION "varying vec2 mask_texture;\n"
"uniform sampler2D mask_sampler;\n"
"uniform vec2 mask_wh;\n"
"uniform vec4 mask_wh;\n"
"vec4 get_mask()\n"
"{\n"
" if (mask_repeat_mode < RepeatFix) \n"
@ -174,7 +174,7 @@ glamor_create_composite_fs(glamor_gl_dispatch * dispatch,
const char *mask_pixmap_fetch =
GLAMOR_DEFAULT_PRECISION "varying vec2 mask_texture;\n"
"uniform sampler2D mask_sampler;\n"
"uniform vec2 mask_wh;\n"
"uniform vec4 mask_wh;\n"
"vec4 get_mask()\n"
"{\n"
" if (mask_repeat_mode < RepeatFix) \n"
@ -538,7 +538,7 @@ glamor_set_composite_texture(ScreenPtr screen, int unit,
glamor_screen_private *glamor_priv =
glamor_get_screen_private(screen);
glamor_gl_dispatch *dispatch;
float wh[2];
float wh[4];
int repeat_type;
dispatch = glamor_get_dispatch(glamor_priv);
@ -605,19 +605,20 @@ glamor_set_composite_texture(ScreenPtr screen, int unit,
/* XXX may be we can eaxctly check whether we need to touch
* the out-of-box area then determine whether we need to fix.
**/
/*if (pixmap_priv->type != GLAMOR_TEXTURE_LARGE)*/ {
if (repeat_type != RepeatNone)
if (repeat_type != RepeatNone)
repeat_type += RepeatFix;
else if (glamor_priv->gl_flavor == GLAMOR_GL_ES2
|| pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
if (picture->transform
|| (GLAMOR_PIXMAP_FBO_NOT_EAXCT_SIZE(pixmap_priv)))
repeat_type += RepeatFix;
else if (glamor_priv->gl_flavor == GLAMOR_GL_ES2
|| pixmap_priv->type == GLAMOR_TEXTURE_LARGE) {
if (picture->transform
|| (GLAMOR_PIXMAP_FBO_NOT_EAXCT_SIZE(pixmap_priv)))
repeat_type += RepeatFix;
}
if (repeat_type >= RepeatFix) {
glamor_pixmap_fbo_fix_wh_ratio(wh, pixmap_priv);
dispatch->glUniform2fv(wh_location, 1, wh);
}
}
if (repeat_type >= RepeatFix) {
glamor_pixmap_fbo_fix_wh_ratio(wh, pixmap_priv);
if (wh[0] != 1.0 || wh[1] != 1.0)
dispatch->glUniform4fv(wh_location, 1, wh);
else
repeat_type -= RepeatFix;
}
dispatch->glUniform1i(repeat_location, repeat_type);
glamor_put_dispatch(glamor_priv);
@ -751,7 +752,7 @@ glamor_setup_composite_vbo(ScreenPtr screen, int n_verts)
dispatch->glBufferData(GL_ARRAY_BUFFER,
n_verts * sizeof(float) * 2,
NULL, GL_DYNAMIC_DRAW);
glamor_priv->vb = dispatch->glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
glamor_priv->vb = dispatch->glMapBuffer(GL_ARRAY_BUFFER, GL_READ_WRITE);
}
dispatch->glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, glamor_priv->ebo);
@ -814,6 +815,8 @@ glamor_emit_composite_vert(ScreenPtr screen,
glamor_priv->vbo_offset += glamor_priv->vb_stride;
}
static void
glamor_flush_composite_rects(ScreenPtr screen)
{
@ -840,22 +843,6 @@ glamor_flush_composite_rects(ScreenPtr screen)
glamor_put_dispatch(glamor_priv);
}
static void
glamor_emit_composite_rect(ScreenPtr screen,
const float *src_coords,
const float *mask_coords,
const float *dst_coords)
{
glamor_emit_composite_vert(screen, src_coords, mask_coords,
dst_coords, 0);
glamor_emit_composite_vert(screen, src_coords, mask_coords,
dst_coords, 1);
glamor_emit_composite_vert(screen, src_coords, mask_coords,
dst_coords, 2);
glamor_emit_composite_vert(screen, src_coords, mask_coords,
dst_coords, 3);
}
int pict_format_combine_tab[][3] = {
{PICT_TYPE_ARGB, PICT_TYPE_A, PICT_TYPE_ARGB},
{PICT_TYPE_ABGR, PICT_TYPE_A, PICT_TYPE_ABGR},
@ -926,34 +913,35 @@ glamor_set_normalize_tcoords_generic(glamor_pixmap_private *priv,
float *matrix,
float xscale, float yscale,
int x1, int y1, int x2, int y2,
int yInverted, float *texcoords)
int yInverted, float *texcoords,
int stride)
{
if (!matrix && repeat_type == RepeatNone)
glamor_set_normalize_tcoords(priv, xscale, yscale,
glamor_set_normalize_tcoords_ext(priv, xscale, yscale,
x1, y1,
x2, y2,
yInverted,
texcoords);
texcoords, stride);
else if (matrix && repeat_type == RepeatNone)
glamor_set_transformed_normalize_tcoords(priv, matrix, xscale,
glamor_set_transformed_normalize_tcoords_ext(priv, matrix, xscale,
yscale, x1, y1,
x2, y2,
yInverted,
texcoords);
texcoords, stride);
else if (!matrix && repeat_type != RepeatNone)
glamor_set_repeat_normalize_tcoords(priv, repeat_type,
glamor_set_repeat_normalize_tcoords_ext(priv, repeat_type,
xscale, yscale,
x1, y1,
x2, y2,
yInverted,
texcoords);
texcoords, stride);
else if (matrix && repeat_type != RepeatNone)
glamor_set_repeat_transformed_normalize_tcoords(priv, repeat_type,
glamor_set_repeat_transformed_normalize_tcoords_ext(priv, repeat_type,
matrix, xscale, yscale,
x1, y1,
x2, y2,
yInverted,
texcoords);
texcoords, stride);
}
Bool glamor_composite_choose_shader(CARD8 op,
@ -1251,7 +1239,7 @@ glamor_composite_with_shader(CARD8 op,
GLfloat mask_xscale = 1, mask_yscale = 1,
src_xscale = 1, src_yscale = 1;
struct shader_key key;
float vertices[8], source_texcoords[8], mask_texcoords[8];
float *vertices;
int dest_x_off, dest_y_off;
int source_x_off, source_y_off;
int mask_x_off, mask_y_off;
@ -1316,11 +1304,12 @@ glamor_composite_with_shader(CARD8 op,
while(nrect) {
int mrect, rect_processed;
int vb_stride;
mrect = nrect > nrect_max ? nrect_max : nrect ;
glamor_setup_composite_vbo(screen, mrect * vert_stride);
rect_processed = mrect;
vb_stride = glamor_priv->vb_stride/sizeof(float);
while (mrect--) {
INT16 x_source;
INT16 y_source;
@ -1342,33 +1331,34 @@ glamor_composite_with_shader(CARD8 op,
DEBUGF("dest(%d,%d) source(%d %d) mask (%d %d), width %d height %d \n",
x_dest, y_dest, x_source, y_source,x_mask,y_mask,width,height);
glamor_set_normalize_vcoords(dest_pixmap_priv, dst_xscale,
vertices = (float*)(glamor_priv->vb + glamor_priv->vbo_offset);
assert(glamor_priv->vbo_offset < glamor_priv->vbo_size - glamor_priv->vb_stride);
glamor_set_normalize_vcoords_ext(dest_pixmap_priv, dst_xscale,
dst_yscale,
x_dest, y_dest,
x_dest + width, y_dest + height,
glamor_priv->yInverted,
vertices);
if (key.source != SHADER_SOURCE_SOLID)
vertices, vb_stride);
vertices += 2;
if (key.source != SHADER_SOURCE_SOLID) {
glamor_set_normalize_tcoords_generic(
source_pixmap_priv, source->repeatType, psrc_matrix,
src_xscale, src_yscale, x_source, y_source,
x_source + width, y_source + height,
glamor_priv->yInverted, source_texcoords);
glamor_priv->yInverted, vertices, vb_stride);
vertices += 2;
}
if (key.mask != SHADER_MASK_NONE
&& key.mask != SHADER_MASK_SOLID)
&& key.mask != SHADER_MASK_SOLID) {
glamor_set_normalize_tcoords_generic(
mask_pixmap_priv, mask->repeatType, pmask_matrix,
mask_xscale, mask_yscale, x_mask, y_mask,
x_mask + width, y_mask + height,
glamor_priv->yInverted, mask_texcoords);
glamor_emit_composite_rect(screen,
source_texcoords,
mask_texcoords,
vertices);
glamor_priv->yInverted, vertices, vb_stride);
}
glamor_priv->render_nr_verts += 4;
glamor_priv->vbo_offset += glamor_priv->vb_stride * 4;
rects++;
}
glamor_flush_composite_rects(screen);
@ -1500,6 +1490,7 @@ glamor_composite_clipped_region(CARD8 op,
y_temp_src = y_source;
x_temp_mask = x_mask;
y_temp_mask = y_mask;
DEBUGF("clipped (%d %d) (%d %d) (%d %d) width %d height %d \n",
x_source, y_source, x_mask, y_mask, x_dest, y_dest, width, height);
@ -1929,7 +1920,6 @@ glamor_composite_glyph_rects(CARD8 op,
ValidatePicture(src);
ValidatePicture(dst);
if (!(glamor_is_large_picture(src)
|| (mask && glamor_is_large_picture(mask))
|| glamor_is_large_picture(dst))) {
@ -1946,7 +1936,6 @@ glamor_composite_glyph_rects(CARD8 op,
mask_pixmap_priv, dst_pixmap_priv, nrect, rects))
return;
}
n = nrect;
r = rects;

View File

@ -124,7 +124,7 @@ _glamor_tile(PixmapPtr pixmap, PixmapPtr tile,
GLfloat dst_xscale, dst_yscale, src_xscale, src_yscale;
glamor_pixmap_private *src_pixmap_priv;
glamor_pixmap_private *dst_pixmap_priv;
float wh[2];
float wh[4];
src_pixmap_priv = glamor_get_pixmap_private(tile);
dst_pixmap_priv = glamor_get_pixmap_private(pixmap);

View File

@ -74,6 +74,8 @@
PIXMAP_PRIV_GET_ACTUAL_SIZE(priv, actual_w, actual_h); \
wh[0] = (float)priv->base.fbo->width / actual_w; \
wh[1] = (float)priv->base.fbo->height / actual_h; \
wh[2] = 1.0 / priv->base.fbo->width; \
wh[3] = 1.0 / priv->base.fbo->height; \
} while(0)
#define pixmap_priv_get_fbo_off(_priv_, _xoff_, _yoff_) \
@ -245,16 +247,11 @@
ty1 = d - priv->box.y1; \
ty2 = ty1 + ((_y2_) - (_y1_)); \
} \
} else if (repeat_type == RepeatNormal) { \
} else { /* RepeatNormal*/ \
tx1 = (c - priv->box.x1); \
ty1 = (d - priv->box.y1); \
tx2 = tx1 + ((_x2_) - (_x1_)); \
ty2 = ty1 + ((_y2_) - (_y1_)); \
} else { \
tx1 = _x1_ - priv->box.x1; \
ty1 = _y1_ - priv->box.y1; \
tx2 = tx1 + ((_x2_) - (_x1_)); \
ty2 = ty1 + ((_y2_) - (_y1_)); \
} \
} while(0)
@ -368,6 +365,28 @@
yInverted); \
} while (0)
#define glamor_set_transformed_normalize_tcoords_ext( priv, \
matrix, \
xscale, \
yscale, \
tx1, ty1, tx2, ty2, \
yInverted, texcoords, \
stride) \
do { \
glamor_set_transformed_point(priv, matrix, xscale, yscale, \
texcoords, tx1, ty1, \
yInverted); \
glamor_set_transformed_point(priv, matrix, xscale, yscale, \
texcoords + 1 * stride, tx2, ty1, \
yInverted); \
glamor_set_transformed_point(priv, matrix, xscale, yscale, \
texcoords + 2 * stride, tx2, ty2, \
yInverted); \
glamor_set_transformed_point(priv, matrix, xscale, yscale, \
texcoords + 3 * stride, tx1, ty2, \
yInverted); \
} while (0)
#define glamor_set_transformed_normalize_tcoords( priv, \
matrix, \
xscale, \
@ -375,20 +394,17 @@
tx1, ty1, tx2, ty2, \
yInverted, texcoords) \
do { \
glamor_set_transformed_point(priv, matrix, xscale, yscale, \
texcoords, tx1, ty1, \
yInverted); \
glamor_set_transformed_point(priv, matrix, xscale, yscale, \
texcoords + 2, tx2, ty1, \
yInverted); \
glamor_set_transformed_point(priv, matrix, xscale, yscale, \
texcoords + 4, tx2, ty2, \
yInverted); \
glamor_set_transformed_point(priv, matrix, xscale, yscale, \
texcoords + 6, tx1, ty2, \
yInverted); \
glamor_set_transformed_normalize_tcoords_ext( priv, \
matrix, \
xscale, \
yscale, \
tx1, ty1, tx2, ty2, \
yInverted, texcoords, \
2); \
} while (0)
#define glamor_set_normalize_tri_tcoords(xscale, \
yscale, \
vtx, \
@ -409,7 +425,7 @@
yInverted); \
} while (0)
#define glamor_set_repeat_transformed_normalize_tcoords( priv, \
#define glamor_set_repeat_transformed_normalize_tcoords_ext( priv, \
repeat_type, \
matrix, \
xscale, \
@ -417,13 +433,14 @@
_x1_, _y1_, \
_x2_, _y2_, \
yInverted, \
texcoords) \
texcoords, \
stride) \
do { \
if (priv->type != GLAMOR_TEXTURE_LARGE) { \
glamor_set_transformed_normalize_tcoords(priv, matrix, xscale, \
glamor_set_transformed_normalize_tcoords_ext(priv, matrix, xscale, \
yscale, _x1_, _y1_, \
_x2_, _y2_, yInverted, \
texcoords); \
texcoords, stride); \
} else { \
/* For a large pixmap, if both transform and repeat are set,
* the transform must only has x and y scale factor.*/ \
@ -453,54 +470,115 @@
_glamor_set_normalize_tpoint(xscale, yscale, ttx1, tty1, \
texcoords, yInverted); \
_glamor_set_normalize_tpoint(xscale, yscale, ttx2, tty2, \
texcoords + 2, yInverted); \
texcoords + 1 * stride, yInverted); \
_glamor_set_normalize_tpoint(xscale, yscale, ttx3, tty3, \
texcoords + 4, yInverted); \
texcoords + 2 * stride, yInverted); \
_glamor_set_normalize_tpoint(xscale, yscale, ttx4, tty4, \
texcoords + 6, yInverted); \
texcoords + 3 * stride, yInverted); \
} \
} while (0)
#define glamor_set_repeat_transformed_normalize_tcoords( priv, \
repeat_type, \
matrix, \
xscale, \
yscale, \
_x1_, _y1_, \
_x2_, _y2_, \
yInverted, \
texcoords) \
do { \
glamor_set_repeat_transformed_normalize_tcoords_ext( priv, \
repeat_type, \
matrix, \
xscale, \
yscale, \
_x1_, _y1_, \
_x2_, _y2_, \
yInverted, \
texcoords, \
2); \
} while (0)
#define _glamor_set_normalize_tcoords(xscale, yscale, tx1, \
ty1, tx2, ty2, \
yInverted, vertices) \
yInverted, vertices, stride) \
do { \
(vertices)[0] = t_from_x_coord_x(xscale, tx1); \
(vertices)[2] = t_from_x_coord_x(xscale, tx2); \
(vertices)[4] = (vertices)[2]; \
(vertices)[6] = (vertices)[0]; \
/* vertices may be write-only, so we use following \
* temporary variable. */ \
float _t0_, _t1_, _t2_, _t5_; \
(vertices)[0] = _t0_ = t_from_x_coord_x(xscale, tx1); \
(vertices)[1 * stride] = _t2_ = t_from_x_coord_x(xscale, tx2); \
(vertices)[2 * stride] = _t2_; \
(vertices)[3 * stride] = _t0_; \
if (yInverted) { \
(vertices)[1] = t_from_x_coord_y_inverted(yscale, ty1); \
(vertices)[5] = t_from_x_coord_y_inverted(yscale, ty2); \
(vertices)[1] = _t1_ = t_from_x_coord_y_inverted(yscale, ty1); \
(vertices)[2 * stride + 1] = _t5_ = t_from_x_coord_y_inverted(yscale, ty2);\
} \
else { \
(vertices)[1] = t_from_x_coord_y(yscale, ty1); \
(vertices)[5] = t_from_x_coord_y(yscale, ty2); \
(vertices)[1] = _t1_ = t_from_x_coord_y(yscale, ty1); \
(vertices)[2 * stride + 1] = _t5_ = t_from_x_coord_y(yscale, ty2);\
} \
(vertices)[3] = (vertices)[1]; \
(vertices)[7] = (vertices)[5]; \
DEBUGF("texture %f %f %f %f\n", tx1, ty1, tx2, ty2); \
DEBUGF("texture %f %f %f %f\n", (vertices)[0], (vertices)[1], \
(vertices)[2], (vertices)[3]); \
DEBUGF("texture %f %f %f %f\n", (vertices)[4], (vertices)[5], \
(vertices)[6], (vertices)[7]); \
(vertices)[1 * stride + 1] = _t1_; \
(vertices)[3 * stride + 1] = _t5_; \
} while(0)
#define glamor_set_normalize_tcoords_ext(priv, xscale, yscale, \
x1, y1, x2, y2, \
yInverted, vertices, stride) \
do { \
if (priv->type == GLAMOR_TEXTURE_LARGE) { \
float tx1, tx2, ty1, ty2; \
int fbo_x_off, fbo_y_off; \
pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off); \
tx1 = x1 + fbo_x_off; \
tx2 = x2 + fbo_x_off; \
ty1 = y1 + fbo_y_off; \
ty2 = y2 + fbo_y_off; \
_glamor_set_normalize_tcoords(xscale, yscale, tx1, ty1, \
tx2, ty2, yInverted, vertices, \
stride); \
} else \
_glamor_set_normalize_tcoords(xscale, yscale, x1, y1, \
x2, y2, yInverted, vertices, stride);\
} while(0)
#define glamor_set_normalize_tcoords(priv, xscale, yscale, \
x1, y1, x2, y2, \
yInverted, vertices) \
do { \
float tx1, tx2, ty1, ty2; \
int fbo_x_off, fbo_y_off; \
pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off); \
tx1 = x1 + fbo_x_off; \
tx2 = x2 + fbo_x_off; \
ty1 = y1 + fbo_y_off; \
ty2 = y2 + fbo_y_off; \
_glamor_set_normalize_tcoords(xscale, yscale, tx1, ty1, \
tx2, ty2, yInverted, vertices); \
glamor_set_normalize_tcoords_ext(priv, xscale, yscale, \
x1, y1, x2, y2, \
yInverted, vertices, 2); \
} while(0)
#define glamor_set_repeat_normalize_tcoords_ext(priv, repeat_type, \
xscale, yscale, \
_x1_, _y1_, _x2_, _y2_, \
yInverted, vertices, stride)\
do { \
if (priv->type == GLAMOR_TEXTURE_LARGE) { \
float tx1, tx2, ty1, ty2; \
if (repeat_type == RepeatPad) { \
tx1 = _x1_ - priv->large.box.x1; \
ty1 = _y1_ - priv->large.box.y1; \
tx2 = tx1 + ((_x2_) - (_x1_)); \
ty2 = ty1 + ((_y2_) - (_y1_)); \
} else { \
glamor_get_repeat_coords((&priv->large), repeat_type, \
tx1, ty1, tx2, ty2, \
_x1_, _y1_, _x2_, _y2_); \
} \
_glamor_set_normalize_tcoords(xscale, yscale, tx1, ty1, \
tx2, ty2, yInverted, vertices, \
stride); \
} else \
_glamor_set_normalize_tcoords(xscale, yscale, _x1_, _y1_, \
_x2_, _y2_, yInverted, vertices, \
stride); \
} while(0)
#define glamor_set_repeat_normalize_tcoords(priv, repeat_type, \
@ -508,16 +586,10 @@
_x1_, _y1_, _x2_, _y2_, \
yInverted, vertices) \
do { \
float tx1, tx2, ty1, ty2; \
if (priv->type == GLAMOR_TEXTURE_LARGE) \
glamor_get_repeat_coords((&priv->large), repeat_type, \
tx1, ty1, tx2, ty2, \
_x1_, _y1_, _x2_, _y2_); \
else { \
tx1 = _x1_; tx2 = _x2_; ty1 = _y1_; ty2 = _y2_; \
} \
_glamor_set_normalize_tcoords(xscale, yscale, tx1, ty1, \
tx2, ty2, yInverted, vertices); \
glamor_set_repeat_normalize_tcoords_ext(priv, repeat_type, \
xscale, yscale, \
_x1_, _y1_, _x2_, _y2_, \
yInverted, vertices, 2); \
} while(0)
#define glamor_set_normalize_tcoords_tri_stripe(xscale, yscale, \
@ -603,26 +675,44 @@
(vertices)[5] = (vertices)[7]; \
} while(0)
#define glamor_set_normalize_vcoords_ext(priv, xscale, yscale, \
x1, y1, x2, y2, \
yInverted, vertices, stride) \
do { \
int fbo_x_off, fbo_y_off; \
/* vertices may be write-only, so we use following \
* temporary variable. */ \
float _t0_, _t1_, _t2_, _t5_; \
pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off); \
(vertices)[0] = _t0_ = v_from_x_coord_x(xscale, x1 + fbo_x_off); \
(vertices)[1 * stride] = _t2_ = v_from_x_coord_x(xscale, \
x2 + fbo_x_off); \
(vertices)[2 * stride] = _t2_; \
(vertices)[3 * stride] = _t0_; \
if (yInverted) { \
(vertices)[1] = _t1_ = v_from_x_coord_y_inverted(yscale, \
y1 + fbo_y_off); \
(vertices)[2 * stride + 1] = _t5_ = \
v_from_x_coord_y_inverted(yscale, \
y2 + fbo_y_off); \
} \
else { \
(vertices)[1] = _t1_ = v_from_x_coord_y(yscale, y1 + fbo_y_off); \
(vertices)[2 * stride + 1] = _t5_ = v_from_x_coord_y(yscale, \
y2 + fbo_y_off); \
} \
(vertices)[1 * stride + 1] = _t1_; \
(vertices)[3 * stride + 1] = _t5_; \
} while(0)
#define glamor_set_normalize_vcoords(priv, xscale, yscale, \
x1, y1, x2, y2, \
yInverted, vertices) \
do { \
int fbo_x_off, fbo_y_off; \
pixmap_priv_get_fbo_off(priv, &fbo_x_off, &fbo_y_off); \
(vertices)[0] = v_from_x_coord_x(xscale, x1 + fbo_x_off); \
(vertices)[2] = v_from_x_coord_x(xscale, x2 + fbo_x_off); \
(vertices)[4] = (vertices)[2]; \
(vertices)[6] = (vertices)[0]; \
if (yInverted) { \
(vertices)[1] = v_from_x_coord_y_inverted(yscale, y1 + fbo_y_off);\
(vertices)[5] = v_from_x_coord_y_inverted(yscale, y2 + fbo_y_off);\
} \
else { \
(vertices)[1] = v_from_x_coord_y(yscale, y1 + fbo_y_off); \
(vertices)[5] = v_from_x_coord_y(yscale, y2 + fbo_y_off); \
} \
(vertices)[3] = (vertices)[1]; \
(vertices)[7] = (vertices)[5]; \
glamor_set_normalize_vcoords_ext(priv, xscale, yscale, \
x1, y1, x2, y2, \
yInverted, vertices, 2); \
} while(0)
#define glamor_set_normalize_vcoords_tri_strip(xscale, yscale, \