glamor: Simplify XV vertex setup.

We were clipping the drawn rectangle to each clip box, then expanding
the box to a big triangle to avoid tearing, then drawing each triangle
to the destination through a scissor.  If we're using a scissor for
clipping, though, then we don't need to clip the drawn primitive on
the CPU in the first place.

Signed-off-by: Eric Anholt <eric@anholt.net>
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Kenneth Graunke <kenneth@whitecape.org>
This commit is contained in:
Eric Anholt 2016-01-26 14:52:08 -08:00
parent 294e45b60d
commit f368a0ba3a

View File

@ -343,45 +343,36 @@ glamor_xv_render(glamor_port_private *port_priv)
glEnable(GL_SCISSOR_TEST); glEnable(GL_SCISSOR_TEST);
v = glamor_get_vbo_space(screen, 16 * sizeof(GLfloat) * nBox, &vbo_offset); v = glamor_get_vbo_space(screen, 3 * 4 * sizeof(GLfloat), &vbo_offset);
for (i = 0; i < nBox; i++) { /* Set up a single primitive covering the area being drawn. We'll
float off_x = box[i].x1 - port_priv->drw_x; * clip it to port_priv->clip using GL scissors instead of just
float off_y = box[i].y1 - port_priv->drw_y; * emitting a GL_QUAD per box, because this way we hopefully avoid
float diff_x = (float) port_priv->src_w / (float) port_priv->dst_w; * diagonal tearing between the two trangles used to rasterize a
float diff_y = (float) port_priv->src_h / (float) port_priv->dst_h; * GL_QUAD.
float srcx, srcy, srcw, srch; */
int dstx, dsty, dstw, dsth; i = 0;
GLfloat *vptr = v + (i * 8); v[i++] = v_from_x_coord_x(dst_xscale, port_priv->drw_x + dst_x_off);
GLfloat *tptr = vptr + (8 * nBox); v[i++] = v_from_x_coord_y(dst_yscale, port_priv->drw_y + dst_y_off);
dstx = box[i].x1 + dst_x_off; v[i++] = v_from_x_coord_x(dst_xscale, port_priv->drw_x + dst_x_off +
dsty = box[i].y1 + dst_y_off; port_priv->dst_w * 2);
dstw = box[i].x2 - box[i].x1; v[i++] = v_from_x_coord_y(dst_yscale, port_priv->drw_y + dst_y_off);
dsth = box[i].y2 - box[i].y1;
srcx = port_priv->src_x + off_x * diff_x; v[i++] = v_from_x_coord_x(dst_xscale, port_priv->drw_x + dst_x_off);
srcy = port_priv->src_y + off_y * diff_y; v[i++] = v_from_x_coord_y(dst_yscale, port_priv->drw_y + dst_y_off +
srcw = (port_priv->src_w * dstw) / (float) port_priv->dst_w; port_priv->dst_h * 2);
srch = (port_priv->src_h * dsth) / (float) port_priv->dst_h;
glamor_set_normalize_vcoords(pixmap_priv, v[i++] = t_from_x_coord_x(src_xscale[0], port_priv->src_x);
dst_xscale, dst_yscale, v[i++] = t_from_x_coord_y(src_yscale[0], port_priv->src_y);
dstx - dstw,
dsty,
dstx + dstw,
dsty + dsth * 2,
vptr);
glamor_set_normalize_tcoords(src_pixmap_priv[0], v[i++] = t_from_x_coord_x(src_xscale[0], port_priv->src_x +
src_xscale[0], port_priv->src_w * 2);
src_yscale[0], v[i++] = t_from_x_coord_y(src_yscale[0], port_priv->src_y);
srcx - srcw,
srcy, v[i++] = t_from_x_coord_x(src_xscale[0], port_priv->src_x);
srcx + srcw, v[i++] = t_from_x_coord_y(src_yscale[0], port_priv->src_y +
srcy + srch * 2, port_priv->src_h * 2);
tptr);
}
glVertexAttribPointer(GLAMOR_VERTEX_POS, 2, glVertexAttribPointer(GLAMOR_VERTEX_POS, 2,
GL_FLOAT, GL_FALSE, GL_FLOAT, GL_FALSE,
@ -389,10 +380,11 @@ glamor_xv_render(glamor_port_private *port_priv)
glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2, glVertexAttribPointer(GLAMOR_VERTEX_SOURCE, 2,
GL_FLOAT, GL_FALSE, GL_FLOAT, GL_FALSE,
2 * sizeof(float), vbo_offset + (nBox * 8 * sizeof(GLfloat))); 2 * sizeof(float), vbo_offset + 6 * sizeof(GLfloat));
glamor_put_vbo_space(screen); glamor_put_vbo_space(screen);
/* Now draw our big triangle, clipped to each of the clip boxes. */
for (i = 0; i < nBox; i++) { for (i = 0; i < nBox; i++) {
int dstx, dsty, dstw, dsth; int dstx, dsty, dstw, dsth;
@ -402,7 +394,7 @@ glamor_xv_render(glamor_port_private *port_priv)
dsth = box[i].y2 - box[i].y1; dsth = box[i].y2 - box[i].y1;
glScissor(dstx, dsty, dstw, dsth); glScissor(dstx, dsty, dstw, dsth);
glDrawArrays(GL_TRIANGLE_FAN, i * 4, 3); glDrawArrays(GL_TRIANGLE_FAN, 0, 3);
} }
glDisable(GL_SCISSOR_TEST); glDisable(GL_SCISSOR_TEST);