[Qt-interest] Comments on: 220548 - X11: Use PictStandardA8 instead of PictStandardA1 in X11 paint engine

Clemens Eisserer linuxhippy at gmail.com
Mon Feb 2 19:33:38 CET 2009


Hi Trond,

> but for me the aliased version is
> about 2 times faster than the antialiased one when running GEARSFANCY.
> Also note that the code path that uses the A1 mask is only used when you
> draw a polygon or path with a texture brush that has an alpha channel.
Are you using EXA or XAA. XAA was basically software-only, and most
mature drivers now use EXA by default.
Practically all recent distributions default to it and when used
carefully (trying to hit no fallbacks), there are some great
performance improvements.

Sun also had problems with it, reverting to software rendering only,
until my XRender backend is completed:
http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6708580


> We can change the A1 mask picture, but I don't see any huge differences
> on my local box. I'm not sure what part of that demo you are looking at
> (GEARSFANCY, GEARS, COMPO or TEXT),
I was reffering to GEARS.
Oh, I misread the code, sorry.
In the non-antialiased case no mask is used at all right?

Using no mask at all is basically the worst thing you can do:
The X-Server iterates through the list of trapezoids, and doing a
"XRenderCompositeTrapezoid" for each trapezoid.
Every time allocating a temporary mask image, uploading it to vram,
compoite and free it.

I wrote a benchmark (attached) drawing a 100x100 circle consisting of
~180 trapezoids:
20ms, fmtA8
120ms, fmtA1
270ms, no mask format
This was on Xorg-1.5.3 / Ubuntu-8.10 / Intel-i945GM

So better use a A1 mask in the mean time, using a mask you also get
rid of the individual texture offset problem.
This way you give at least Xorg a chance to do the right things.

However, I was wrong about simply replacing A1 with A8, because this
still results in antialiased rendering, even if
XRenderPictureAttributes.polyEdge == PolyEdgeSharp.
The right thing would probably to use A8 internally in Xorg when A1 is
requested and switch to aliased rendering.
I will have a look and discuss it on Xorg.


> Needless to say, this is suboptimal - however there is a reason for it.
> The texture offsets are reset for every trapezoid that is rendered (at
> least it is in every RENDER implementation I've tested). We need to
> adjust the offset for each individual trapezoid to get the correct output.
Wow I also was not aware of this. However using a mask seems to solve it :)

>> 3.) qt_XRenderCompositeTrapezoids:
>> This seems to be a work-arround, however it breaks antialiasing :-/
>
> Why does it break antialiasing?
Because Trapezoids are in the antialiased case added with PictOpAdd,
so two overlapping edged with 0.5 will give 1.0.
However, when compositing you have your own operator, so at the edges
between the traps in the first go and the traps of the second go you
won't have PictOpAdd that makes it look seamless,
but instead the value resulting of your chosen operator. (e.g. for
PictOpOver 0.5+0.5 ~ 0.75)
However this is a very uncommon problem, not very likely to occur.


Thanks for listening, Clemens


Xorg code for Trapezoid rendering:

void
exaTrapezoids (CARD8 op, PicturePtr pSrc, PicturePtr pDst,
              PictFormatPtr maskFormat, INT16 xSrc, INT16 ySrc,
              int ntrap, xTrapezoid *traps)
{
   if (maskFormat) {
        //Allocate image in RAM
        //Clear its contents
       //Render trapezoids to it using CPU
       //Upload to VRAM and composite
       //Free the temporary picture, as well as its cached VRAM copy
   } else {
       if (pDst->polyEdge == PolyEdgeSharp)
           maskFormat = PictureMatchFormat (pScreen, 1, PICT_a1);
       else
           maskFormat = PictureMatchFormat (pScreen, 8, PICT_a8);
       for (; ntrap; ntrap--, traps++)
           exaTrapezoids (op, pSrc, pDst, maskFormat, xSrc, ySrc, 1, traps);
   }
}



More information about the Qt-interest-old mailing list