[Qt-interest] Comments on: 220548 - X11: Use PictStandardA8 instead of PictStandardA1 in X11 paint engine
Clemens Eisserer
linuxhippy at gmail.com
Sun Feb 1 19:16:04 CET 2009
Hello,
Ever since switching to QT4 I saw suboptimal performance on Linux compared
to QT3.
I did some profiling and found some problems in the way how QT4 uses the
XRender API:
1.) QT's paint engine renders trapezoids into a A1 mask picture in the
aliased case.
However using A1 surfaces as mask isn't support by modern GPUs, thats the
case why Cairo as well as my XRender Java2D backend use A8 masks everywhere.
This is causing heavy migration ping-pong, where pixmap contents are moved
back and forth between system memory and VRAM.
The same is true for the font-engine, it uses A1 masks to store aliased
glyphs.
However Xorg-1.6 contains some work-arrounds to use A8 always, and convert
the uploaded glpyhs to A8.
The problem can be easily seen with QGears2, with antialiasing it reaches
about 80fps on my intel i945GM, with antialiasing off only ~20fps.
2.) When using a fill-texture:
An explicit mask image is created, the trapezoids are *blended* using an
implicit/temporary mask image, composition happends and then the mask image
is freed.
I guess there is some reason why the code does look like this, but its
extremly inefficient, especially with all the quirks EXA has.
Why not simply call XRenderCompositeTrapezoids with the texture as source?
3.) qt_XRenderCompositeTrapezoids:
This seems to be a work-arround, however it breaks antialiasing :-/
4.) In the fill-texture case where depth==1:
Each trapezoids is composited one after another.
For each trapezoids the following happens:
1. Allocate temporary mask pixmap
2. Render the trapezoid in software
3. Copy software-generated image to VRAM
4. Composite using the GPU
Don't know if anybody every benchmarked this on EXA, but this will lead to
horrible performance.
I would be really happy about feedback, would be great if at least the
common cases could be fixed in QT-4.5.
Thanks, Clemens
qpaintengine_x11.cpp: 1566:
if (tessellator->size > 0) {
> XRenderPictureAttributes attrs;
> attrs.poly_edge = antialias ? PolyEdgeSmooth : PolyEdgeSharp;
> XRenderChangePicture(dpy, picture, CPPolyEdge, &attrs);
>
> if (has_fill_texture) {
> if (fill.texture().depth() == 1) {
> for (int i=0; i < tessellator->size; ++i) {
> int x_offset =
> int(XFixedToDouble(tessellator->traps[i].left.p1.x) - bg_origin.x());
> int y_offset =
> int(XFixedToDouble(tessellator->traps[i].left.p1.y) - bg_origin.y());
> XRenderCompositeTrapezoids(dpy, composition_mode,
> src, picture,
> antialias ?
> XRenderFindStandardFormat(dpy, PictStandardA8) : 0,
> x_offset, y_offset,
> tessellator->traps + i,
> 1);
> }
> } else {
> int mask_w = br.width() + (br.x() > 0 ? br.x() : 0);
> int mask_h = br.height() + (br.y() > 0 ? br.y() : 0);
> Pixmap mask = XCreatePixmap (dpy, RootWindow(dpy, scrn),
> mask_w, mask_h, antialias ?
> 8 : 1);
> Picture mask_picture = XRenderCreatePicture (dpy, mask,
> antialias ?
> XRenderFindStandardFormat(dpy, PictStandardA8)
> :
> XRenderFindStandardFormat(dpy, PictStandardA1),
> CPPolyEdge,
> &attrs);
> XRenderColor transparent;
> transparent.red = 0;
> transparent.green = 0;
> transparent.blue = 0;
> transparent.alpha = 0;
> XRenderFillRectangle(dpy, PictOpSrc, mask_picture,
> &transparent, 0, 0, mask_w, mask_h);
>
> Picture mask_src = X11->getSolidFill(scrn, Qt::white);
> qt_XRenderCompositeTrapezoids(dpy, PictOpOver, mask_src,
> mask_picture,
> antialias ?
> XRenderFindStandardFormat(dpy, PictStandardA8) : 0,
> 0, 0,
> tessellator->traps,
> tessellator->size);
> XRenderComposite(dpy, composition_mode, src,
> mask_picture, picture,
> qRound(-bg_origin.x()),
> qRound(-bg_origin.y()),
> 0, 0,
> 0, 0,
> mask_w, mask_h);
> XFreePixmap(dpy, mask);
> XRenderFreePicture(dpy, mask_picture);
> }
> } else {
> qt_XRenderCompositeTrapezoids(dpy, composition_mode, src,
> picture,
> antialias ?
> XRenderFindStandardFormat(dpy, PictStandardA8) : 0,
> 0, 0,
> tessellator->traps,
> tessellator->size);
> }
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.qt-project.org/pipermail/qt-interest-old/attachments/20090201/3f7e3614/attachment.html
More information about the Qt-interest-old
mailing list