Fallback to pixman when trapezoid mask is big.
The trapezoid generating speed of the shader is relatively slower when the trapezoid area is big. We fallback when the trapezoid's width and height is bigger enough. The big traps number will also slow down the render because of the VBO size. We fallback if ntrap > 256 Signed-off-by: Junyan He <junyan.he@linux.intel.com> Reviewed-By: Zhigang Gong <zhigang.gong@linux.intel.com>
This commit is contained in:
parent
f62f4d53ef
commit
c3096c5a56
|
@ -1016,7 +1016,7 @@ glamor_composite_rectangles(CARD8 op,
|
||||||
|
|
||||||
#define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
|
#define GLAMOR_PIXMAP_DYNAMIC_UPLOAD
|
||||||
#define GLAMOR_GRADIENT_SHADER
|
#define GLAMOR_GRADIENT_SHADER
|
||||||
//#define GLAMOR_TRAPEZOID_SHADER
|
#define GLAMOR_TRAPEZOID_SHADER
|
||||||
#define GLAMOR_TEXTURED_LARGE_PIXMAP 1
|
#define GLAMOR_TEXTURED_LARGE_PIXMAP 1
|
||||||
#define WALKAROUND_LARGE_TEXTURE_MAP
|
#define WALKAROUND_LARGE_TEXTURE_MAP
|
||||||
#if 0
|
#if 0
|
||||||
|
|
|
@ -36,6 +36,28 @@
|
||||||
#include "mipict.h"
|
#include "mipict.h"
|
||||||
#include "fbpict.h"
|
#include "fbpict.h"
|
||||||
|
|
||||||
|
static xFixed
|
||||||
|
_glamor_linefixedX (xLineFixed *l, xFixed y, Bool ceil)
|
||||||
|
{
|
||||||
|
xFixed dx = l->p2.x - l->p1.x;
|
||||||
|
xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx;
|
||||||
|
xFixed dy = l->p2.y - l->p1.y;
|
||||||
|
if (ceil)
|
||||||
|
ex += (dy - 1);
|
||||||
|
return l->p1.x + (xFixed) (ex / dy);
|
||||||
|
}
|
||||||
|
|
||||||
|
static xFixed
|
||||||
|
_glamor_linefixedY (xLineFixed *l, xFixed x, Bool ceil)
|
||||||
|
{
|
||||||
|
xFixed dy = l->p2.y - l->p1.y;
|
||||||
|
xFixed_32_32 ey = (xFixed_32_32) (x - l->p1.x) * dy;
|
||||||
|
xFixed dx = l->p2.x - l->p1.x;
|
||||||
|
if (ceil)
|
||||||
|
ey += (dx - 1);
|
||||||
|
return l->p1.y + (xFixed) (ey / dx);
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef GLAMOR_TRAPEZOID_SHADER
|
#ifdef GLAMOR_TRAPEZOID_SHADER
|
||||||
|
|
||||||
#define GLAMOR_VERTEX_TOP_BOTTOM (GLAMOR_VERTEX_SOURCE + 1)
|
#define GLAMOR_VERTEX_TOP_BOTTOM (GLAMOR_VERTEX_SOURCE + 1)
|
||||||
|
@ -72,28 +94,6 @@ _glamor_lines_crossfixedY (xLineFixed *l, xLineFixed *r)
|
||||||
return 0xFFFFFFFF;
|
return 0xFFFFFFFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
static xFixed
|
|
||||||
_glamor_linefixedX (xLineFixed *l, xFixed y, Bool ceil)
|
|
||||||
{
|
|
||||||
xFixed dx = l->p2.x - l->p1.x;
|
|
||||||
xFixed_32_32 ex = (xFixed_32_32) (y - l->p1.y) * dx;
|
|
||||||
xFixed dy = l->p2.y - l->p1.y;
|
|
||||||
if (ceil)
|
|
||||||
ex += (dy - 1);
|
|
||||||
return l->p1.x + (xFixed) (ex / dy);
|
|
||||||
}
|
|
||||||
|
|
||||||
static xFixed
|
|
||||||
_glamor_linefixedY (xLineFixed *l, xFixed x, Bool ceil)
|
|
||||||
{
|
|
||||||
xFixed dy = l->p2.y - l->p1.y;
|
|
||||||
xFixed_32_32 ey = (xFixed_32_32) (x - l->p1.x) * dy;
|
|
||||||
xFixed dx = l->p2.x - l->p1.x;
|
|
||||||
if (ceil)
|
|
||||||
ey += (dx - 1);
|
|
||||||
return l->p1.y + (xFixed) (ey / dx);
|
|
||||||
}
|
|
||||||
|
|
||||||
static Bool
|
static Bool
|
||||||
point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
point_inside_trapezoid(int point[2], xTrapezoid * trap, xFixed cut_y)
|
||||||
{
|
{
|
||||||
|
@ -1601,6 +1601,45 @@ glamor_create_mask_picture(ScreenPtr screen,
|
||||||
return picture;
|
return picture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
_glamor_trapezoid_bounds (int ntrap, xTrapezoid *traps, BoxPtr box)
|
||||||
|
{
|
||||||
|
box->y1 = MAXSHORT;
|
||||||
|
box->y2 = MINSHORT;
|
||||||
|
box->x1 = MAXSHORT;
|
||||||
|
box->x2 = MINSHORT;
|
||||||
|
int has_large_trapezoid = 0;
|
||||||
|
|
||||||
|
for (; ntrap; ntrap--, traps++) {
|
||||||
|
INT16 x1, y1, x2, y2;
|
||||||
|
|
||||||
|
if (!xTrapezoidValid(traps))
|
||||||
|
continue;
|
||||||
|
y1 = xFixedToInt (traps->top);
|
||||||
|
if (y1 < box->y1)
|
||||||
|
box->y1 = y1;
|
||||||
|
|
||||||
|
y2 = xFixedToInt (xFixedCeil (traps->bottom));
|
||||||
|
if (y2 > box->y2)
|
||||||
|
box->y2 = y2;
|
||||||
|
|
||||||
|
x1 = xFixedToInt (min (_glamor_linefixedX (&traps->left, traps->top, FALSE),
|
||||||
|
_glamor_linefixedX (&traps->left, traps->bottom, FALSE)));
|
||||||
|
if (x1 < box->x1)
|
||||||
|
box->x1 = x1;
|
||||||
|
|
||||||
|
x2 = xFixedToInt (xFixedCeil (max (_glamor_linefixedX (&traps->right, traps->top, TRUE),
|
||||||
|
_glamor_linefixedX (&traps->right, traps->bottom, TRUE))));
|
||||||
|
if (x2 > box->x2)
|
||||||
|
box->x2 = x2;
|
||||||
|
|
||||||
|
if (!has_large_trapezoid && (x2 - x1) > 256 && (y2 - y1) > 32)
|
||||||
|
has_large_trapezoid = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return has_large_trapezoid;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* glamor_trapezoids will first try to create a trapezoid mask using shader,
|
* glamor_trapezoids will first try to create a trapezoid mask using shader,
|
||||||
* if failed, miTrapezoids will generate trapezoid mask accumulating in
|
* if failed, miTrapezoids will generate trapezoid mask accumulating in
|
||||||
|
@ -1621,6 +1660,7 @@ _glamor_trapezoids(CARD8 op,
|
||||||
PixmapPtr pixmap;
|
PixmapPtr pixmap;
|
||||||
pixman_image_t *image = NULL;
|
pixman_image_t *image = NULL;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
|
int has_large_trapezoid;
|
||||||
|
|
||||||
/* If a mask format wasn't provided, we get to choose, but behavior should
|
/* If a mask format wasn't provided, we get to choose, but behavior should
|
||||||
* be as if there was no temporary mask the traps were accumulated into.
|
* be as if there was no temporary mask the traps were accumulated into.
|
||||||
|
@ -1638,10 +1678,10 @@ _glamor_trapezoids(CARD8 op,
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
miTrapezoidBounds(ntrap, traps, &bounds);
|
has_large_trapezoid = _glamor_trapezoid_bounds(ntrap, traps, &bounds);
|
||||||
DEBUGF("The bounds for all traps is: bounds.x1 = %d, bounds.x2 = %d, "
|
DEBUGF("The bounds for all traps is: bounds.x1 = %d, bounds.x2 = %d, "
|
||||||
"bounds.y1 = %d, bounds.y2 = %d\n", bounds.x1, bounds.x2,
|
"bounds.y1 = %d, bounds.y2 = %d, ---- ntrap = %d\n", bounds.x1,
|
||||||
bounds.y1, bounds.y2);
|
bounds.x2, bounds.y1, bounds.y2, ntrap);
|
||||||
|
|
||||||
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
|
if (bounds.y1 >= bounds.y2 || bounds.x1 >= bounds.x2)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
|
@ -1666,16 +1706,20 @@ _glamor_trapezoids(CARD8 op,
|
||||||
When the depth is not 1, AA is needed and we use a shader to generate
|
When the depth is not 1, AA is needed and we use a shader to generate
|
||||||
a temp mask pixmap.
|
a temp mask pixmap.
|
||||||
*/
|
*/
|
||||||
if(mask_format->depth == 1) {
|
if (mask_format->depth == 1) {
|
||||||
ret = _glamor_trapezoids_with_shader(op, src, dst, mask_format,
|
ret = _glamor_trapezoids_with_shader(op, src, dst, mask_format,
|
||||||
x_src, y_src, ntrap, traps);
|
x_src, y_src, ntrap, traps);
|
||||||
if(ret)
|
if(ret)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
} else {
|
} else {
|
||||||
/* The precise mode is that we sample the trapezoid on the centre points of
|
if (has_large_trapezoid || ntrap > 256) {
|
||||||
an (2*n+1)x(2*n-1) subpixel grid. It is computationally expensive in shader
|
/* The shader speed is relative slower than pixman when generating big chunk
|
||||||
and we use inside area ratio to replace it if the polymode == Imprecise. */
|
trapezoid mask. We fallback to pixman to improve the performance. */
|
||||||
if(dst->polyMode == PolyModeImprecise) {
|
;
|
||||||
|
} else if (dst->polyMode == PolyModeImprecise) {
|
||||||
|
/* The precise mode is that we sample the trapezoid on the centre points of
|
||||||
|
an (2*n+1)x(2*n-1) subpixel grid. It is computationally expensive in shader
|
||||||
|
and we use inside area ratio to replace it if the polymode == Imprecise. */
|
||||||
picture = glamor_create_mask_picture(screen, dst, mask_format,
|
picture = glamor_create_mask_picture(screen, dst, mask_format,
|
||||||
width, height, 1);
|
width, height, 1);
|
||||||
if (!picture)
|
if (!picture)
|
||||||
|
|
Loading…
Reference in New Issue